Materialui-从哪里加载CSS类? [英] Materialui - where to load CSS classes from?

查看:36
本文介绍了Materialui-从哪里加载CSS类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能有一个快速的答案.我开始学习Material UI,并想尝试其网格示例,但是下面的代码提到编译被拒绝为NOTFOUND ..无法找到要加载的CSS文件来尝试这些示例..没有className参数,我看不到任何轮廓GRID,因此这些css'classes.root'可能拥有格式选项.感谢您的帮助,

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}>

推荐答案

您需要使用 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>
  );
}

这篇关于Materialui-从哪里加载CSS类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆