2021-12-02 15:58:59
1、html代码
<template>
<el-tree
ref="treeBox"
node-key="id"
highlight-current
default-expand-all
:data="data"
:props="defaultProps"
:expand-on-click-node="false">
</el-tree>
</template>
2、js代码
export default {
data() {
return {
data: [{
id:1,
label: '一级 1',
children: [{
id:2,
label: '二级 1-1'
}]
}],
defaultProps: {
children: 'children',
label: 'label'
}
};
},
mounted(){
this.$nextTick(() => {
this.$refs.treeBox.setCurrentKey(2);
});
}
}
3、css代码
.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content{
background: #409eff!important;
color: white!important;
}
最后生成于 2023-06-27 21:38:00
热门推荐: