当子组件调用$emit传递参数
this.$emit('commit',{a: 1, b: 2})
父组件接收
<children
@commit='commit'
></children>
commit(e){
console.log(e);//{a: 1, b: 2}
}
那么父组件有参数需要传入时
<children
@commit='commit($event,key)'
></children>
data(){
return{
key: 1,
}
},
commit(e,key){
console.log(e,key);//{a: 1, b: 2},1
}