我试图摆脱Material-UI主题中的阴影。

我找到了这个answer here with fixed the problem。但是,我在此问题的标题中收到错误消息。

const theme = createMuiTheme({
  palette: {
    primary: {
      light: red[300],
      main: red[500],
      dark: red[700]
    },
    secondary: {
      light: red.A200,
      main: red.A400,
      dark: red.A700
    }
  },
  shadows: ['none']
});

错误:



我找到了这个解决方案,但是答案没有帮助:
https://github.com/mui-org/material-ui/issues/8289

最佳答案

看起来它希望您的主题至少有 25 个阴影,以便创建在 Material UI 中看到的进度。如果您尝试遵循 Material UI 标准,我当然不建议删除阴影,但一种简单的方法可能只是将所有高度级别设置为 none

const theme = createMuiTheme({
  palette: {
    primary: {
      light: red[300],
      main: red[500],
      dark: red[700]
    },
    secondary: {
      light: red.A200,
      main: red.A400,
      dark: red.A700
    }
  },
  shadows: Array(25).fill('none')
});
这应该满足要求。
编辑:
正如 Dave 所指出的,如果您使用的是 TypeScript,请记住进行强制转换:
shadows: Array(25).fill('none') as Shadows

关于javascript - Material-UI:提供给createMuiTheme的阴影数组应支持25个高程,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50516398/

10-16 12:56