【发布时间】:2018-10-26 12:48:34
【问题描述】:
目前我正在努力将MenuItem 组件的背景颜色设置为不同的颜色。 (无需使用 !important 强制它)
组件代码:
<MenuItem
classes={{
root: this.props.classes.root,
selected: this.props.classes.selected
}}
value={10}>
Alfabetical
</MenuItem>
这是css:
const homePageStyle = (theme) => ({
root: {
width: "300px"
},
selected: {
backgroundColor: "turquoise !important",
color: "white",
fontWeight: 600
}
});
我想达到什么目标?
我想设置 MenuItem 的 backgroundColor 而不必设置 !important 标志。我已经用很多组件做到了这一点,但目前这似乎无法解决。
我正在使用版本“@material-ui/core”:“^1.0.0-rc.0”,
【问题讨论】:
-
你用的是什么版本的material-ui?
-
@ArnaudChrist 我正在使用“@material-ui/core”:“^1.0.0-rc.0”,
-
正确答案是这里的第一个答案:stackoverflow.com/questions/49439266/…
标签: reactjs material-ui jss