浅谈VUE,使用watch方法监听父组件传到子组件的数据。
时间:2020-03-31 00:40:06
收藏:0
阅读:1167
props:[‘updateData‘], data(){ return{ form: { _name:‘‘, }, } },
第一步接收数据:
props:[‘updateData‘]
第二步动态改变值:
mounted(){ this.form._name = this.updateData._name; },
第三步使用watch监听 updateData数据
watch:{
updateData: function (newVal ,oldVal){ //不能用箭头函数
this.form._name = newVal._name
}
}
原文:https://www.cnblogs.com/yetiezhu/p/12602344.html
评论(0)