可以通过覆盖特定属性的样式来解决这个问题。下面是一个示例:
// 重置导航栏颜色
.ant-menu-horizontal {
&.ant-menu-dark .ant-menu-item-selected {
background-color: #1890ff; // 改变选中项的背景颜色(同时也解决了colorPrimary所影响的问题)
}
&.ant-menu-dark .ant-menu-item::after {
border-right: 2px solid #1890ff; // 改变未选中项的边框颜色(若为红色,则colorPrimary的影响将继续存在)
}
&.ant-menu-dark .ant-menu-item:hover,
&.ant-menu-dark .ant-menu-item-active,
&.ant-menu-dark .ant-menu-item-selected {
color: #fff; // 改变字体颜色
}
}
通过在样式表中显式地设置具体的颜色值,即可解决colorPrimary样式所造成的不希望影响到的属性变化。
上一篇:antd中的表格高度问题(React+AntDesign)
下一篇:antd中的DatePicker抛出错误:“无法找到dayjsGenerateConfig的导入:从'rc-picker/lib/generate/dayjs'。”