Vue watch

作者: leslie1943 | 来源:发表于2019-05-08 13:52 被阅读0次

Vue中监听某个对象的属性

为了避免监听整个对象导致效率问题,可以监听某个对象的特定属性

     watch: {
    'deptModel.depts': {
      handler(newVal, oldVal) {
        if (oldVal.length == 4 && newVal.length == 5) {
          this.deptModel.depts = oldVal
          this.$message.warning('最多选择4个科室')
        }
      }
    }
  }

相关文章

网友评论

      本文标题:Vue watch

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