let obj ={ count=1 }
/方法1/
watch(obj,()=>{
console.log(1);
},{
deep:true //可以不写
immediate: true//一进入组件就自动监听
})
方法2
watch(()=>obj.count,()=>{
console.log(2)
},{
deep:true //可以不写
})
方法3
watch([obj1,obj2],()=>{
console.log(3)
},{
deep:true //可以不写
})
watch(()=>obj,()=>{
console.log(4)
},{
deep:true // 必须写
})
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111