在 Blazorise Treeview 中更改图标

Change an icon in Blazorise Treeview

我正在使用 Blazorise Treeview,但找不到如何更改用于打开和关闭节点的默认图标。该组件强烈依赖于 fa-plus-square 和 fa-minus-square,我不知道如何自定义它。
我可以在官方文档中找到一些有用的东西:Blazorise Treeview Documentation.
This problem is mentioned in an issue https://github.com/Megabit/Blazorise/issues/994 不确定是否有是一个解决方案。

嘿,我认为唯一的解决办法是覆盖以下样式

.fa-plus-square:before {
    content: "\f0fe" !important; // Replace the content by another icon from font awesome
}

但要小心,有些图标需要特定的 font-weight。因此,例如要用十字代替,我需要:

.far.fa-plus-square {
    font-weight: 900 !important;
}
.fa-plus-square:before {
    content: "\f00d" !important;
}

您可能需要一些更具体的 CSS 选择器来覆盖库的包含样式,但这绝对是实现它的方法 - 在 github 问题得到解决之前。

编辑:仅增加一个信息,此修改将覆盖图标本身的样式,但您可能在项目的其他地方需要它们,因此我建议您将整个 Treeview 组件封装在一个专用的 div 和 class,并调整我编写的 CSS 选择器以包含新的 class。 (.far.fa-plus-square 变成 .my-tree-view-container .far.fa-plus-square)