我正在制作一个简单地扩展普通 html 输入的组件。
const Input: React.FC<HTMLAttributes<HTMLInputElement>> = (...props }) => <input {...props}} />
逻辑很简单,我采用通常的 html 输入,制作一个组件并传递道具。一般来说,所有的 props 都是正常滚动的(placeholder、value、onChange、className 等),但是 props 有问题type
。
尝试将类型分配给组件<Input type="text" />
时,会发生以下错误:
Type '{ type: string; }' is not assignable to type 'IntrinsicAttributes & HTMLAttributes<HTMLInputElement> & { children?: ReactNode; }'.
Property 'type' does not exist on type 'IntrinsicAttributes & HTMLAttributes<HTMLInputElement> & { children?: ReactNode; }'.
一般来说,我做错了什么,但我不明白到底是什么。