如果是多层级树,等树加载完成后执行以下语句:
this.$nextTick(() => {
document
.querySelector('[role=group] .el-tree-node__children .el-tree-node__content')
.click();
});
如:
activated () {
this.$http({
url: this.$http.adornUrl('/menuList'),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.menuList = treeDataTranslate(data.menuList)
} else {
this.menuList = []
}
}).then(() => {
this.$nextTick(() => {
document
.querySelector('[role=group] .el-tree-node__children .el-tree-node__content')
.click();
});
})
}
如果觉得树的选中颜色太浅,可以修改css:
<style lang="scss" >
.el-tree-node.is-current > .el-tree-node__content {
background-color: #c2d6ea !important;
}
</style>