美文网首页
watch 监听

watch 监听

作者: LUOTAOLUOTAO | 来源:发表于2020-05-12 11:51 被阅读0次
    • 普通 watch
    watch: {
      value (newValue, oldValue) {
        console.log(newValue)
      }
    }
    
    • 数组 watch
    watch: {
      arr: {
        handler (newValue, oldValue) {
          console.log(newValue)
        },
        deep: true
      }
    }
    
    • 对象 watch
    watch: {
      obj: {
        handler (newValue, oldValue) {
          console.log(newValue)
        },
        deep: true
      }
    }
    
    • 对象的具体属性 watch
    watch: {
       'obj.name' (newValue, oldValue) {
        console.log(newValue)
      }
    }
    

    相关文章

      网友评论

          本文标题:watch 监听

          本文链接:https://www.haomeiwen.com/subject/uxqbnhtx.html