网站导航
> 资讯中心 > 学习园地 > Vue中$emit
Vue中$emit
2021-12-25

$emit传递一个参数时

子组件:

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

父组件:

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

$emit传递多个参数时

子组件:

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

父组件:

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