vue element-ui tree 根节点固定子节点懒加载 首次加载根节点并展开
关键代码:
<el-tree ref="foldTree" node-key="id" :highlight-current="true" :props="defaultProps" lazy :load="handLoadNode" @node-click="handleNodeClick" />
data() { return { CurrentNode: null, CurrentNodeResolve: null, RootNode: { id: "000", Name: "根目录", Path: "" }, } },
mounted() { var _rNode = this.CurrentNode.childNodes[0]; _rNode.checked = true; _rNode.expanded = true; _rNode.loadData(); }
handLoadNode(node, resolve) { this.CurrentNodeResolve = resolve; this.CurrentNode = node; if (node.level === 0) { return resolve([this.RootNode]); } else { ... } }