<el-tree
:data="treeData"
node-key="id" //这行不能少,必须是id
ref="tree" //这行不能少
highlight-current //这行不能少
default-expand-all
:props="defaultProps"
@node-click="handleNodeClick"></el-tree>
//默认高亮指定行
this.$nextTick().then(() =>{
this.$refs['tree'].setCurrentKey(this.treeData[0].id); // 必须!!!!
});
注意:一定要写上this.$nextTick 否则不生效