Loading

watch的深度监听

vue3中的watch默认deep为true

经踩坑发现,下面俩种情况不会开启

1 当监视的对象author属性obj也为对象时,必须开启deep

      const author = reactive({
        name: 'John Doe',
        obj:{id:0,t:2},
        books: [
          'Vue 2 - Advanced Guide',
          'Vue 3 - Basic Guide',
          'Vue 4 - The Mystery'
        ],
        bage: computed(()=>{
          return count.value+1
        })
      })

2 当监视的对象count 为ref定义的对象时,必须开启deep

      let count = ref({
        id:0
      })

posted @ 2023-05-20 16:47  梧桐树211  阅读(111)  评论(0编辑  收藏  举报