vue 子组件向父组件传递多个参数
2020-06-25 本文已影响0人
Cideal
this.$emit('事件名',[a,b,c...]) // a,b,c... 是父组件内接收的实参
<!-- 子组件中定义goToDetail 事件 -->
<div class="good" v-for="(item, index) in goodsList" :key="index"
:goodsID="item.goodsID" goodstype=""
:style="{backgroundColor: backgroundColor}"
@click="goToetail(item)">
<img class="good-img" :src="item.headPic">
</div>
methods: {
goToDetail(item){
this.$emit("goToDetail",[item,111,222])
},
},
<!-- 父组件 接收goToDetail-->
<Goods @goToDetail="goToDetail"/>
<!-- 父组件 methods 中定义一下-->
methods: {
goToDetail(item,a,b){
console.log(item,a,b)
},
}
