vue2 watch引用类型 失败原因

vue中watch基本用法: 

new Vue({
            el: '#t1',
            data: {
                a: {
                    b: 1,
                    c: 2
                },
            },
            methods: {
                ch() {
           this.a.d=5     //不打印ok 原理是watch只watch挂在data中的数据,初始化时给他们分别赋予setter与getter,如果是中途加上的属性,由于没有setter与getter,不会被watch到。
           this.a.c=5    //打印ok ,测试时与上面代码只写一个。 } },
watch: {           a:{
            handler(){
              console.log('ok')
            },
            deep:true
          } },
)}
//html:
<div class='t1' id='t1'>
  <button @click='ch'>+++</button>
</div>
 

})

原文地址:https://www.cnblogs.com/gsgs/p/6821819.html