vue-监听(watch)

1.监听某个字段

watch: {
    svalue(val, oldVal) {
      if (val !== oldVal) {
        this.$emit("input", this.svalue)
      }
    }
  }

2.监听对象

  watch: {
    form: {
      deep: true,
      handler(newval) {
        this.data = newval
      }
    }
  }

3.监听对象的某个属性

  watch: {
    'form.sfyx0': {
      deep: true,
      handler(newval) {
        this.btn= true
      }
    }
  }

 

posted @ 2021-07-12 15:59  一个小机灵  阅读(226)  评论(0编辑  收藏  举报