【问题标题】:MaterialUI - How to apply useStyle() and normal classes in the same className attributeMaterial UI - 如何在同一个 className 属性中应用 useState() 和普通类
【发布时间】:2019-12-16 12:22:30
【问题描述】:

我在我的 React 项目中使用 MaterialUI,我想在我的组件中使用一个 useStyle() 类和一个常规类。也许代码会更好地解释它:

...

const useStyles = makeStyles(theme => ({
   fontSizeGrid: {
      fontSize: 12,
   },
}));

...

const classes = useStyles();

...


<Typography className="my-auto font-weight-bold {classes.fontSizeGrid}">Test!</Typography>

...

上面的示例不起作用,因为它将所有内容都置于“字符串模式”。我怎样才能实现我想要的?

【问题讨论】:

    标签: reactjs class styles material-ui


    【解决方案1】:

    应该这样做:

    <Typography className="my-auto font-weight-bold" classes={{root: classes.fontSizeGrid}}>Test!</Typography>
    
    

    Material-UI 排版 API:https://material-ui.com/es/api/typography/

    类(对象):覆盖或扩展应用于组件的样式。有关详细信息,请参阅下面的 CSS API。

    【讨论】:

    • 现在试试,抱歉。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多