子组件向父组件传值,为了增加回调函数的复用性,事件绑定采用函数式编程,但是总是不能正确调用实例方法返回的函数:
<slideDown
:choosestyle="chooseStyle"
:useroptions="useroptions1"
@changeSubData="receiveData(prodMoneyOff)"
></slideDown>
data () {
message: {
prodMoneyOff: ''
}
},
methods: {
receiveData (item) {
let _self = this
console.log(`选择的item是${item}`)
return function (val) {
console.log(`传递的值是 ${val}`)
_self.message[item] = val
}
}
}
慕容森
相关分类