vue access props from method code example
Example 1: vue get props into data
props : {
users : Array,
currentuser: Number,
todoId : Number
},
mounted() {
this.current = this.currentuser
},
data(){
return{
current: null
}
Example 2: 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')
}
}