Material-ui类名称在构建时发生更改,向每个类名称添加了标识符,这些标识符被用户覆盖 [英] Material-ui classes name changes on build, adds identifiers to each class name that are overriden by user

查看:42
本文介绍了Material-ui类名称在构建时发生更改,向每个类名称添加了标识符,这些标识符被用户覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是当使用的类= {{blah blah}}时,它在本地运行良好,默认的材料类名称也没有标识符.但是在其他机器上,css崩溃了,在检查出问题之后,我才知道className生成器或某些我不知道的东西,通过向我使用的className添加计数器编号来更改覆盖.所以现在看起来像这样.

The problem is when used classes={{blah blah}}, it was working fine locally also default material class names were having no identifiers. But on some other machine the css broke, after checking what went wrong I came to know that className generator or something I don't know what, changed my overrides by adding counter number to the classNames I have used. So now it looks something like this.

现在,我也不想再次重写css,因为这是您重写Mui类的方式.生产情况糟透了.

Now I don't want to rewrite css again also I can't because this is how you override Mui classes. Production build sucks.

'&.MuiSelect-blah':{一些CSS * wooosh}

'& .MuiSelect-blah':{ some css *wooosh }

推荐答案

在App主文件中尝试:

Try in App main file:

 import React from 'react';
 import { StylesProvider, createGenerateClassName } from '@material-ui/core/styles';

 const generateClassName = createGenerateClassName({
   productionPrefix: 'some',
 });

 export default function App() {
    return (
     <StylesProvider generateClassName={generateClassName}>...</StylesProvider>
   );
 }

这篇关于Material-ui类名称在构建时发生更改,向每个类名称添加了标识符,这些标识符被用户覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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