小编Cle*_*ost的帖子

Material UI v5 - 在 TypeScript 中扩展版式变体会产生错误“没有重载与此调用匹配”

我正在使用 Material UI v5 和 TypeScript 为应用程序设置基础。我想使用一些添加到现有默认属性的自定义属性来扩展 Material UI 主题。

我的 theme.ts 配置如下所示:

import { createTheme, ThemeOptions } from "@mui/material/styles";

interface IThemeOptions extends ThemeOptions {}

export const themeStyles = {
    palette: {...},
    breakpoints: {...},
    typography: {
        h1: {...},
        h2: {...},
        h3: {...},
        h4: {...},
        h5: {...}
        h6: {...},
        button: {...},
        body1: {...},
        body2: {...},
        //this is the custom prop I want to add
        h1Bold: {
            fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
            fontWeight: 700,
            fontSize: "3.3125rem",
            lineHeight: "1.15em",
            color: "#1D1D1D",
            marginTop: "20px", …
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs material-ui

28
推荐指数
2
解决办法
2万
查看次数

标签 统计

javascript ×1

material-ui ×1

reactjs ×1

typescript ×1