你所做的是正确的。
为了让它在全球范围内包裹你的应用程序
MuiThemeProvider
阻碍
例如:
import { createMuiTheme } from '@material-ui/core/styles';
import { MuiThemeProvider } from '@material-ui/core/styles';
const theme = createMuiTheme({
palette: {
primary: {
// light: will be calculated from palette.primary.main,
main: '#ff4400',
// dark: will be calculated from palette.primary.main,
// contrastText: will be calculated to contrast with palette.primary.main
},
secondary: {
light: '#0066ff',
main: '#0044ff',
// dark: will be calculated from palette.secondary.main,
contrastText: '#ffcc00',
},
// error: will use the default color
},
});
export default class App extends Component {
render() {
return (
<MuiThemeProvider theme={theme}>
< your application code >
</MuiThemeProvider>
);
}
希望这对你有帮助。