<el-tree :props="props" :load="loadNode" lazy></el-tree>
loadNode(node, resolve) {
//加载数据的方法里把node,reslove存起来
this.node = node;
this.resolve = resolve;
// 把子节点清空,否则下次加载时会直接往里push子节点导致重复
this.node.childNodes = [];
this.$http.get({
url: url,
successCallback: res => {
resolve(res.data);
},
failCallback: res => {
console.log(res);
}
});
},
refreshData(){
//手动调用加载数据方法
this.loadNode(this.node,this.reslove);
}