el-tree|el-tree 复选框回显问题

watch: { filterText(val) { this.$refs.tree.filter(val); } }, methods:{ filterNode(value, data) { if (!value) return true; return data.label.indexOf(value) !== -1; } } //编辑回显 showEdit(row) { vm.$nextTick(function(){ this.visibleDia = true; this.getTreeList().then(res => { if (res && res.length !== 0) { this.$refs.tree.setCheckedKeys("返回的子节点id的数组"); //注意,不要带父节点id } else { this.dataTree = []; } }) }) }, // 获取树列表 getTreeList () { return new Promise(resolve => { this.$http.post({}).then(res => { this.dataTree = res.data.treeList; resolve(this.dataTree); }) }) }, //提交 submit() { console.log(this.$refs.tree.getCheckedKeys()) //当前选中的节点id console.log(this.$refs.tree.getHalfCheckedKeys()) //当前半选中状态也就是父节点的id var idList =(this.$refs.tree.getCheckedKeys()).concat(this.$refs.tree.getHalfCheckedKeys()) // 提交接口,分开传选中节点id数组,和选中加半选中状态数组 }, //关闭 close () { this.defaultCheckedKeys = this.$refs.tree.setCheckedKeys([]); this.visibleDia = false; },

【el-tree|el-tree 复选框回显问题】

    推荐阅读