Answers for "vue access props from method"

Go
0

vue get props into data

props : {
        users : Array,
        currentuser: Number,
        todoId : Number
    },
    mounted() {
        this.current = this.currentuser
    },
    data(){
        return{
            current: null
        }
Posted by: Guest on October-01-2020
1

pass method as props vue

//You should probably not pass methods as props in Vue, instead, emit an event.

//In parent component, do for example:

<Child-Component @alert="sayHi" />

methods: {
  sayHi() {
	alert('Hi')
  }
}

// In child component, do:

<element @click="doSomething">

methods: {
  doSomething() {
  	this.$emit('alert')
  }
}
Posted by: Guest on October-25-2020
0

vuejs accessing props from data

data: function() {
  var theData = {
    somevar: this.messageId,
    // other object attributes
  }

  return theData;
}
Posted by: Guest on June-30-2020

Browse Popular Code Answers by Language