<child
:mockParent="handleParentEvet"
></child>
props:{
mockParent:{
type: Function
}
},
methods:{
handle(){
this.mockParent(‘param from child‘)
// 不能使用 this.$emit(‘mockParent‘,‘sssss‘)
}
}
<child
@test="parentTest"
@update="parentUpdate"
></child>
methods:{
handle(){
this.$listeners.test(‘param from child test‘) // OK
this.$listeners.update(‘param from child update‘) // OK
this.$emit(‘update‘,‘param from child update‘) // OK
}
}
原文:https://www.cnblogs.com/leslie1943/p/13625953.html