Vue中this.$emit函数传递一个或者多个参数的写法,多种传值,传多个值

一个参数:
子组件:

this.$emit('closeChange',false);

父组件:

<posilCom @closeChange="closeCom($event)"></posilCom>
closeCom(msg) {
    this.msg = msg;
}

 


 

多个参数:
子组件:

this.$emit('closeChange',false,true);

父组件:接收的时候要传 arguments参数

<posilCom @closeChange="closeCom(arguments)"></posilCom>
closeCom(msg) {
    this.msg1 = msg[0];
    this.msg2 = msg[1];
}

https://blog.csdn.net/asd1170586462/article/details/106480673/

 

 

posted @ 2021-11-22 13:53  Shimily  阅读(2795)  评论(0)    收藏  举报