data中定义一个对象:
data(){
return{
obj:{
name:'tom',
age:24,
gender:'男'
}
}
}
例如现在我想要监听obj中的name和age属性,那么此时,首先在计算属性中,筛出一个新的对象
computed:{
'newObj':function(){
const {name,age} = this.obj
return {name,age}
}
},
接着在watch中进行监听新的对象
watch:{
newObj:function(){
alert(1)
}
},