/** * 初始化左侧树 * @param {*} GetDataLists */ SetTreeDatas() { let _this = this; _this.$API.SysDictDataGetLeftdata().then((res) => { _this.treeData = res.data.data; //给树赋值 this.$nextTick(() => { this.$refs.treeList && this.$refs.treeList.setCurrentKey(this.treeData[0].ID); //默认选中第一条 this.handleNodeClick(this.treeData[0]); //同时调用树点击事件 }); }); }, <el-tree style="height: 40rem" :data="treeData" :props="defaultProps" @node-click="handleNodeClick" node-key="ID" default-expand-all highlight-current :key="itemKey" ref="treeList"></el-tree>