小编Joh*_*son的帖子

How tosolve 指的是一个值,但在这里被用作类型。您的意思是“typeof DatePicker”吗?

我将 ReactJs 与 TypeScript 和 AntDesign 结合使用,但遇到了问题。

我有返回 AntDesignComponent 的函数,但 typeScript 抛出错误。

“TextArea”指的是一个值,但在这里被用作类型。您的意思是“typeof TextArea”吗?ts(2749)

算术运算的左侧必须是“any”、“number”、“bigint”类型或枚举类型。ts(2362)

算术运算的左侧必须是“any”、“number”、“bigint”类型或枚举类型。ts(2362)

将“string”类型转换为“Input”类型可能是一个错误,因为两种类型都没有与另一种类型充分重叠。如果这是故意的,请将表达式转换为“未知”first.ts(2352)

export const getTypeFormElem = ({
  type = 'input',
  typeValue = 'text',
  ...props
}) => {
  if (type === 'textarea') return <TextArea value='123' { ...props } />;
  if (type === 'checkbox') return <Checkbox { ...props } />;
  if (type === 'date') return <DatePicker { ...props } />;
  return <Input type={ typeValue } {...props } />;
};
Run Code Online (Sandbox Code Playgroud)

进口组件

功能

你能解释一下如何解决这个问题以及我做错了什么吗?

typescript reactjs antd

1
推荐指数
1
解决办法
7811
查看次数

如何在文档组件中的nextjs中获取语言环境?

我想在脚本谷歌地图中设置区域设置,如下所示:

<script defer src={`https://maps.googleapis.com/maps/api/js?key=key&libraries=places&language=${locale}`}/>
Run Code Online (Sandbox Code Playgroud)

但我怎样才能到达文档 nextJS 中的区域设置?useRouter 在文档组件中不起作用。

export default function Document() {
  return (
    <Html>
      <Head>
        <link rel="preconnect" href="https://fonts.googleapis.com" />
       
      
<script defer src={`https://maps.googleapis.com/maps/api/js?key=key&libraries=places&language=${locale}`}/> 
      </Head>

      <body>
        <Main />
        <NextScript />
      </body>
    </Html>
  );
}
Run Code Online (Sandbox Code Playgroud)

next.js

1
推荐指数
1
解决办法
1126
查看次数

标签 统计

antd ×1

next.js ×1

reactjs ×1

typescript ×1