[vue] watch怎么深度监听对象变化
'a.b.c', 然后直接解析到c那层, 绑定observer
'obj.xx': {
handler: function(val) {},
deep:true
}
deep设置为true 就可以监听到对象的变化
let vm=new Vue({
el:"#first",
data:{msg:{name:'北京'}},
watch:{
msg:{
handler (newMsg,oldMsg){
console.log(newMsg);
},
immediate:true,
deep:true
}
}
})
Most helpful comment