【问题标题】:React Material UI randomize/remove MUI class namesReact Material UI 随机化/删除 MUI 类名
【发布时间】:2021-03-20 17:54:31
【问题描述】:

是否可以随机化名称或删除 Mui-classNames?

如上图所示? (所有 CSS 类名都是 jssXXX)谢谢

【问题讨论】:

    标签: javascript reactjs material-ui


    【解决方案1】:

    jssXXX 这样的类名是丑化的结果,在为生产模式构建项目时将由 Material UI 自动生成。例如当您运行 npm run build 时,如果使用 create-react-app 创建的应用程序。

    className 应按以下方式创建,以便 Material UI 处理它:

    import React from 'react';
    import { createStyles, Theme, makeStyles } from "@material-ui/core";
    
    const CustomMuiTheme = makeStyles((theme: Theme) => createStyles({
      label: {
        color: red,
      }
    });
    const theme = CustomMuiTheme();
    
    export const CssClassDemo = () => {
      return (
        <label className={theme.label}>label text</label>
      );
    }
    

    仅由用户创建的类将被丑化。 Material UI 提供的诸如 MuiGrid-container 之类的类不会被缩小,因为它为开发人员提供了自定义这些样式的机会。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-05
      • 2022-07-22
      • 1970-01-01
      相关资源
      最近更新 更多