1.使用Vue提供的deep方法
data(){
return {
arr:[],
obj:{somechange:''}
}
}
//百度都说数组和对象一样,不知道为啥我试了数组没成功
watch:{
obj{
handler:function(newValue, oldValue){
//只要对象里面有一个属性变换就会执行
},
deep:true, //深度监听
}
}
2.其他
watch:{
'obj.somechange':{
handler:function(newValue, oldValue){
//只要对象里面有一个属性变换就会执行
},
}
}
computed: {
changed() {
return this.obj.changesomething
}
},
watch: {
changed(newValue, oldValue) {
console.log(newValue)
}
}
目前使用过‘对象.属性’