@on-change="onParamChange('buyNum', $event)"
来源:7-5 购买详情页 - 数字组件

qq_爱非坚持_0
2018-02-09
子组件通过 "on-change"自定义事件传过来的 this.number 为什么父组件这里,这里要这样写,$event是什么意思?有啥作用?一直没明白
写回答
1回答
-
fishenal
2018-02-10
这里我是通过事件的$event,将自定义事件传的值强行赋值给onParamChange方法,这里写的不是很标准,之前这么做是为了不同事件公用一个onParamChange,我建议将方法拆开,不在html里传参,这么写:
html:
<v-selection :selections="buyTypes" @on-change="onBuyTypeParamChange"></v-selection>
js:
...
onBuyTypeParamChange (chosenObj) {
this['buyType'] = chosenObj
this.getPrice()
},
...
$emit的时候写入了参数,传递到onBuyTypeParamChange方法里。
关于$event的迷惑都可以用这个方法处理,其他相关问题也看一下。
00
相似问题