首页 > 解决方案 > 如何为 H1/H2/.. 标签应用站点范围的样式?

问题描述

我曾经这样做:

import {createMuiTheme} from '@material-ui/core/styles';

export const theme = createMuiTheme({
  typography: {
    h1: {
      fontSize: '2.85em',
      margin: '0 0 16px', // <-- dies 
    },
    // ..
});

但是编译器死了说边距不能分配给 TypographyStyleOptions。

  TS2326: Types of property 'h1' are incompatible.

输入'{字体大小:字符串;边距:字符串;}' 不可分配给类型 'TypographyStyleOptions'。对象字面量只能指定已知属性,并且类型“TypographyStyleOptions”中不存在“边距”。

在我更新一些软件包之前它曾经工作过。

在这里为每个组件应用样式对我不起作用,因为我需要在 Markdown 渲染器中使用这些样式,它不会输出 React 组件

标签: typescriptmaterial-ui

解决方案


推荐阅读