ReactJS Typescript 类型的参数 '{ keyPrefix: string; }' 不可分配给字符串类型的参数
ReactJS Typescript Argument of type '{ keyPrefix: string; }' is not assignable to parameter of type string
只有几个类似的问题,而且这两个问题的解决方案都不适用于我的情况。这是给出此错误的代码片段:
homepage.tsx 文件:
export const CTASection = () => {
const {t, i18n} = useTranslation( {keyPrefix:("homepage.ctaSection")} )
return (
<StyledSection>
<CTAContainer>
<Header>{t('Header')}</Header>
<Subtitle>
Play and learn <i>risk-free</i>. Prove your knowledge, speculate and
win!
</Subtitle>
.....
我的 JSON 文件:
[
{
"homepage": {
"ctaSection": {
"header": "some thing"
}
}
}
]
我实际上是在尝试使用 JSON 文件的内容显示在主页上的 header 部分,而我实际得到的是错误。
根据Doc.
选项在第二个参数上
const { t } = useTranslation('', { keyPrefix: 'homepage.ctaSection' });
只有几个类似的问题,而且这两个问题的解决方案都不适用于我的情况。这是给出此错误的代码片段:
homepage.tsx 文件:
export const CTASection = () => {
const {t, i18n} = useTranslation( {keyPrefix:("homepage.ctaSection")} )
return (
<StyledSection>
<CTAContainer>
<Header>{t('Header')}</Header>
<Subtitle>
Play and learn <i>risk-free</i>. Prove your knowledge, speculate and
win!
</Subtitle>
.....
我的 JSON 文件:
[
{
"homepage": {
"ctaSection": {
"header": "some thing"
}
}
}
]
我实际上是在尝试使用 JSON 文件的内容显示在主页上的 header 部分,而我实际得到的是错误。
根据Doc.
选项在第二个参数上const { t } = useTranslation('', { keyPrefix: 'homepage.ctaSection' });