一,对整个对象监视

watch:{
 obj:{
  handler(newV,oldV){
   console.log('obj changed')
  },
  deep: true,//深度遍历
  immediate: true//默认false,设置为true会立即执行
 }
}

二,对指定key进行监视

watch: {
    "dataobj.name": {
      handler(newV, oldV) {
        console.log("obj changed");
      }
    }
  }

三,结合computed

computed(){
 ar(){
  return this.obj.name
 }
},
watch:{
 ar(newV,oldV){
   console.log('changed')
 }
}

相关文章:

  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案