直接上干货
data(){
node: {},
resolveFunc: function () {},
},
/**
* 重载树
*/
reloadTree() {
this.node.childNodes = []
this.loadNode(this.node, this.resolveFunc)
}
//懒加载
loadNode(node, resolve) {
let _this = this
if (node.level === 0) {
_this.node = node
_this.resolveFunc = resolve //重点
_this.getTree(resolve) //重点
}
if (node.level === 1) {
_this.getChildTree(node, resolve)
}
if (node.level > 1) {
_this.getChildTree(node, resolve)
}
},