Joh*_*son 1 typescript reactjs antd
我将 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)
你能解释一下如何解决这个问题以及我做错了什么吗?
| 归档时间: |
|
| 查看次数: |
7811 次 |
| 最近记录: |