Vue 深度监听对象或者对象指定属性

4,481 阅读1分钟

1,深度监听对象

通过deep:true

props:['pageData'],
data(){
    return{
       
    }
},
  watch:{
       pageData:{
                handler: function (newval, oldVal) {
                    console.log(newval)
                },
                deep: true
            }
        }  
        

2,深度监控对象的指定属性

watch: {
    "object.name": {
        handler(newName, oldName) {
           console.log("object.name变化了 ")
        },
        deep: true
    }
}