el-tree 默认选中第一个数据

 

/**
     * 初始化左侧树
     * @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>

猜你喜欢

转载自blog.csdn.net/CMDN123456/article/details/132472924
今日推荐