vue watch 深度检测

vue yekong 23℃
import _ from 'lodash'
  watch: {
    item: {
      handler (newVal) {
        console.log(newVal)
        this.getdata2()
      },
      deep: true  //开启深度监听 只要对象中任何一个属性变化 都会触发'对象的侦听器'
    },
    data: {
      handler (newVal) {
        console.log(newVal)
        this.getdata()
      },
      deep: true  //开启深度监听 只要对象中任何一个属性变化 都会触发'对象的侦听器'
    },
  },
getdata () {
      this.$emit('update:item', this.data)
            this.$nextTick(() => {
        this.$forceUpdate()
      })
    },
    getdata2 () {
      this.data = _.cloneDeep(this.item)
            this.$nextTick(() => {
        this.$forceUpdate()
      })
    }
喜欢 (0)