在tree的:load方法中,将默认参数node,resolve两个参数存放到全局变量中;
在对树节点进行操作后,对全局变量中的node.childNodes赋值为[空数组],
最后重新调用tree的:load方法(参数为存放在全局的变量);
代码如下:
<el-tree
ref="tree2"
:props="props"
:load="loadNode"
lazy node-key="lable"
show-checkbox check-strictly
@check="handleCheckChange">
...
</el-tree>
loadNode(node, resolve) {
...
if (node.data.type == 1){
this.tree_node = node;
this.tree_resolve = resolve;
...
return resolve(res.data);
})
}
}
},
/* 删除节点后重载树 操作节点后调用方法 */标签:node,load,resolve,...,tree,element,loadNode,ui,重载 From: https://www.cnblogs.com/kaoo-kiee/p/17329042.html
reloadTree(){
this.tree_node.childNodes = [];
this.loadNode(this.tree_node,this.tree_resolve);
},