watch: { "treeId": function (newVal, oldVal) { this.handleGetTree(newVal) }, "activeTree": function (newVal, oldVal) { this.defaultCheckTreeId = []; console.log(newVal,"第二个树的新制") this.defaultCheckTreeId.push(newVal.id); // this.handleGetTree(newVal.id) }, },
在<el-tree>遇到
如
activeTree:{
name:"",
id:1
}
如果是对象里面的id变了是不可以的 必须整体 this.activeTree = {},才能监听到activeTree对象值发生改变
意思就是我们这一次和上一次传过去的属性值一样,watch 监听的属性因为没有新的变化(这次的值和上一次的值一样watch 中调用的函数不执行