使用vue2.x自定義事件可否傳遞多個參數(shù)?子組件
<button @click="setEvent">自定義事件傳參</button>
methods:{
setEvent () { this.$emit('getEvent','參數(shù)一','參數(shù)二')
}
}
父組件
<child-event @getEvent="handlerEvent"></child-event>
methods:{
handlerEvent ($event) {
console.log($event)
}
}父組件怎么才能同時接收到子組件的兩個(多個參數(shù))?
2 回答

幕布斯6054654
TA貢獻1876條經(jīng)驗 獲得超7個贊
// 父組件<child-event @getEvent="handlerEvent"></child-event> methods:{ // p1,p2 ,就是你要的參數(shù) handlerEvent (p1,p2) { console.log(p1,p2) } }
添加回答
舉報
0/150
提交
取消