1. 深度监听对象的变化
data: {
  obj: {
       age: 18     
    } 
},
watch: {
    obj: {
         handler(newVal, oldVal){
             
        },
         deep: true
    }
}         
  1. 监听对象的某个属性变化
data: {
  obj: {
    age: 18
  }
},
computed: {
  isage(){
    return this.obj.age
  }
},
watch: {
  isage(){
  console.log('obj.age发生变化')
  }
}
  
Logo

前往低代码交流专区

更多推荐