Vue 深度监听
data() {
return {
dateshow: true,
show: false,
model: {}
}
},
watch: {
model: {
handler: function(newValue) {
console.log('chnage---', newValue)
this.$emit('handlerValue', {
value: newValue,
rules: this.list.rules
})
},
immediate: true,
deep: true
}
},
虽然对对象进行了深度监听,但是通过方法对数据进行修改时,视图是发生了变化,但是watch并没有监听到
confirmHandler(arr) {
console.log('xialaxuanze', arr)
this.model[this.list.model] = arr[0].label
}
如何让watch 监听到数据的变化 this.$set(target,key,value)
confirmHandler(arr) {
console.log('xialaxuanze', arr)
this.$set(this.model,this.list.model,arr[0].label)
}