版式组件 [英] Typography component

查看:60
本文介绍了版式组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据此处的材料ui文档: https://material-ui.com/components/印刷术/

According to the material ui docs here: https://material-ui.com/components/typography/

我应该能够如下使用Typography组件:

I should be able to use the Typography component as follows:

<Typography variant="h1" component="h1">
  Hello World
</Typography>

但是,由于更新到nextjs 9,所以出现此输入错误:

However, since updating to nextjs 9, I get this typing error:

Type 'string' is not assignable to type 'ElementType<HTMLAttributes<HTMLElement>>'

表示组件属性.我试过一堆更新打字依赖,但似乎无济于事.

for the component property. I've tried updating the typing dependencies a bunch, but nothing seems to help.

由于Shanon的建议,该错误现已转移至:

Thanks to Shanon's suggestion, the error has now moved on to:

48:36 Type '"h1"' is not assignable to type 'ElementType<HTMLAttributes<HTMLElement>>'.
    46 |         </Grid>
    47 |         <Grid item>
  > 48 |           <Typography variant="h1" component={'h1' as const}>
       |                                    ^
    49 |             Hello World
    50 |           </Typography>
    51 |         </Grid>

对我来说,这仍然是一个障碍.

Which is still a blocker for me.

鉴于我给出的第一个示例与文档完全匹配,因此我对如何推进该主题一无所知.

Given the first example I gave matches the docs exactly, I'm at a loss for how to progress the subject.

推荐答案

使用 component = {'div'as any} 对我有用.

这篇关于版式组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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