美文网首页
VUE watch多个data数据

VUE watch多个data数据

作者: callPromise | 来源:发表于2020-04-20 00:02 被阅读0次
data() {
  return {
    num1: 0,
    num2: 0,
    num3: 0,
    count: 0
  }
},
computed{
  num() {
    const { num1, num2, num3 } = this
    return { num1, num2, num3 }
  }
},
watch: {
  num: {
    handler(obj) {
      const { num1, num2, num3 } = obj
      this.count = this.plusU(num1, num2, num3)
    },
    immediate: true,
    deep: true
  }
},
method: {
  plusU(n1, n2, n3) {
    return n1 + n2 + n3
  }
}

相关文章

网友评论

      本文标题:VUE watch多个data数据

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