我发现了某种错误或其他问题..仍然不知道。我有一个React应用,material-ui可用作UI。例如,当您导入按钮时,您可以使用primary={true}或更改其颜色secondary={true}。但是,我决定改变primary和secondary颜色。我发现我可以这样做:
const theme = createMuiTheme({
palette: {
primary: '#00bcd4',
secondary: '#ff4081'
}
});
Run Code Online (Sandbox Code Playgroud)
然后在这里我可以使用它:
<MuiThemeProvider theme={theme}>
<App/>
</MuiThemeProvider>
Run Code Online (Sandbox Code Playgroud)
但我得到一个错误: createMuiTheme is not a function...
我进入material-ui包装,发现没有这样的文件,当我导入时createMuiTheme我得到了undefined。它应该是从导入的,material-ui/styles/theme但我实际上根本没有此文件夹!
我正在使用material-ui@0.19.4。我将此软件包更新为,v20..并且仍然没有此类文件夹...
怎么知道如何解决这个问题?
使用 Material-UI 创建颜色主题时,我将对比文本设置为白色 (#fff)。它适用于具有主要颜色的按钮,但不适用于次要颜色。
按此处所述尝试覆盖:材料 UI:无法更改主题中的按钮文本颜色。如果覆盖可以解决它,那么我需要帮助编写一个。
const colortheme = createMuiTheme({
palette: {
primary: { main: '#e91e63' },
secondary: { main: '#03a9f4' },
contrastText: '#fff',
}
});
Run Code Online (Sandbox Code Playgroud)
期望两个按钮都有白色文本。取而代之的是一键黑色:
编辑:我创建了主题并在父级上呈现 Material UI 的 SimpleModal 组件,将主题道具传递给子级。该按钮呈现在孩子身上。
家长:
const blues = createMuiTheme({
palette: {
primary: { main: '#00e5ff' },
secondary: { main: '#2979ff' },
contrastText: '#fff'
}
})
<SimpleModal label="content" theme={blues} color="primary" document="content" />
Run Code Online (Sandbox Code Playgroud)
孩子:
<div>
<MuiThemeProvider theme={this.props.theme}>
<Button className={classes.margin} variant="contained" color={this.props.color} onClick={this.handleOpen}>{this.props.label}</Button>
</MuiThemeProvider>
<Modal open={this.state.open} onClose={this.handleClose}>
<div style={getModalStyle()} className={classes.paper}>
<Typography variant="h6" …Run Code Online (Sandbox Code Playgroud)