【发布时间】:2021-06-02 21:10:37
【问题描述】:
我使用https://codesandbox.io/s/github/SabuShakya/React-Sidebar-Using-Material-UI/ 一个作为参考, 我想将appbar的背景更新为#ffb74d,
我已经检查了很多答案,答案在我尝试过的其他项目中对我有用,但同样的方法在这个项目中无济于事,我不知道这里出了什么问题
以下代码是我在 MiniDrawer.js 中添加的,它没有按预期工作
const theme = createMuiTheme({
palette: {
primary: {
// Purple and green play nicely together.
main: '#0fb7ae',
},
secondary: {
// This is green.A700 as hex.
main: '#11cb5f',
},
},
});
....
<ThemeProvider theme={theme}>
<AppBar
position="fixed"
color={theme.palette.primary.main}
.......
有人帮帮我吗?
【问题讨论】:
-
你能提供你的代码的sn-p吗?
-
加了我累的代码
-
只需将颜色更改为 backgroundColor 即可。通过仅将颜色放在里面的元素会像文本或图标一样改变颜色。
标签: reactjs material-ui appbar