javascript - React:更改 TreeSelect 的背景颜色(antD 组件)
问题描述
我正在尝试更改antD的 TreeSelect 组件的背景颜色
尝试了这些方法:
// const bgColor = element.Style !== undefined && element.Style === Constants.StyleModes.MAJOR ?
// "#CFECF5" : "white" //TODO - didn't override the ant-select-selector
// const listStyle = element.Style !== undefined && element.Style === Constants.StyleModes.MAJOR ?
// "small-font styled-element" : "small-font"
elements.push(
<td className="view-cell" align="left">
{element.Name}
<br/>
<TreeSelect
className="small-font"
style={{ width: '100%', fontSize: 'small' /*, backgroundColor: bgColor*/}}
但它没有生效;如果我将“!important”添加到bgColor const,则在检查元素时样式不会显示在元素中,但是如果我删除了其中显示的重要但未生效以导致antD样式“ant-select-selector”更强并且覆盖它:
如果我将此样式添加到我的 css 中,它将影响所有列表,我只想根据某些逻辑设置特定的样式:
.ant-select-selector {
background-color: #CFECF5 !important;
}
解决方案
推荐阅读
- bluetooth - iOS Core蓝牙外设扫描问题:如何区分多个设备同时广告
- javascript - 根据 XML 属性的值更改图像
- api - 我们可以使用 Github API 来确定 Github 用户是否是机器人吗?
- pandas - 如何在一个月的最后一周添加 1 并在 pandas 数据框中填充为 0?
- r - r 多列减法
- java - Gradle 项目的简单版本控制
- jquery - JQuery在每行中创建动态对象数组
- amazon-elastic-beanstalk - 运行 eb init 时出现 Elastic Beanstalk 错误
- javascript - Microsoft Visual Studio 是否有布局编辑器?
- jpa - 根据多选列表中提供/未提供的值动态生成 jpql 查询