项目中使用el-tree进行筛选表格,想要选中某节点时高亮显示,综合查的资料进行总结
1. :highlight-current="isShowGaoliang"为true或者false决定是否需要树高亮显示
<el-tree :expand-on-click-node="false" ref="myTree" node-key="id"
@node-click="setIssue" :default-expand-all="false" :check-strictly="true" :data="deptTypes" :highlight-current="isShowGaoliang" >
</el-tree>
2.通过点击树的某一节点设置isShowGaoliang为true,并通过获得该节点id,使该节点高亮this.$refs.deptTree.setCurrentKey(data.id)
setIssue(data, node, tree) {
this.$nextTick(() => {
// 使树筛选时选中的节点高亮显示
this.isShowGaoliang = true
this.$refs.deptTree.setCurrentKey(data.id)
})