【问题标题】:Failed to change the appbar backgroud color更改应用栏背景颜色失败
【发布时间】: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


【解决方案1】:

你可以试试这个 Appbar 背景颜色

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-26
    • 1970-01-01
    • 2019-11-20
    • 2016-10-16
    • 2015-02-25
    • 2010-11-19
    • 2016-08-20
    • 1970-01-01
    相关资源
    最近更新 更多