0%

vue $emit 传递多个参数

$emit 传递一个参数
1
2
3
4
5
6
7
8
//子组件
this.$emit('changeValue',value);

//父组件
<posilCom @changeValue="handleValue(val)"></posilCom>
handleValue(val) {
this.val = val;
}
$emit 传递多个参数
1
2
3
4
5
6
7
8
9
//子组件
this.$emit('changeValue',value,true);

//父组件
<posilCom @changeValue="handleValue(arguments)"></posilCom>
handleValue(arr) {
this.val = arr[0];
this.isActive = arr[1];
}