问题
This might have a quick answer. I am starting to learn Material UI and want try its grid examples, but coding below mentions that compilation rejects as NOTFOUND .. Could not locate a CSS file to load to try these examples.. Without the className parameter, i do not see any outline of the GRID, so may be these css 'classes.root' hold the formatting options. Appreciate your kind help,
function App() {
return (
<div className={classes.root}> ????
<Grid container spacing={3}>
<Grid item xs={12}>
回答1:
You need to use makeStyles
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
const useStyles = makeStyles({
root: {
backgroundColor: 'red',
color: props => props.color,
},
});
function App(props) {
const classes = useStyles(props);
return (
<div className={classes.root}>
// ...
</div>
);
}
来源:https://stackoverflow.com/questions/62650170/materialui-where-to-load-css-classes-from