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/

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM