组件属性:highlight-current-row是否高亮当前选中节点默认值是 false。代码如下: el-form ref=queryFormRef model=queryParams label-position=right label-width=90px div class=flex justify-between
你可以通过自定义样式来实现将选中的节点设置为红色。可以在你的CSS文件中添加以下样式:
.el-tree-node.is-current > .el-tree-node__content {
color: red;
}
然后在你的HTML代码中,将highlight-current-row属性设置为true,并绑定一个选中节点的属性,例如selectedNodeId。然后通过动态绑定class的方式,将选中的节点添加is-current类名。
<el-tree :data="treeData" :props="defaultProps" node-key="categoryId" highlight-current-row :default-expanded-keys="[selectedNodeId]"
@node-click="handleClick" />
这样,当你选中一个节点时,该节点的文本颜色将变为红色。
原文地址: http://www.cveoy.top/t/topic/iG0x 著作权归作者所有。请勿转载和采集!