<div class='tree'>
            <el-tree :data="treeList" :highlight-current="highLight" ref="treeList" :load="getTree"  :render-content="renderContent" :expand-on-click-node='false' :default-expanded-keys='[0]' node-key='id' :props="defaultProps" @node-click="handleNodeClick" lazy></el-tree>
        </div>

设置highlight-current为true,设置ref="treeList"

     created(){
         
            this.$nextTick(function(){
                this.$refs.treeList.setCurrentKey(0);  //"treeList"是你自己在树形控件上设置的 ref="treeList" 的名称
            })
           
        },

vue created方法中调用setCurrentKey方法设置根节点高亮

Logo

前往低代码交流专区

更多推荐