React Typescript:只读:true;不能分配给'DetailedHTMLProps <InputHTMLAttributes <HTMLInputElement>'类型,

时间:2019-11-11 07:45:57

标签: reactjs typescript

我正在尝试使输入字段为只读

<input type='text' name='email' readonly />

我得到的错误是

Type '{ type: string; name: string; readonly: true; }' is not assignable to type 'DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>'.
  Property 'readonly' does not exist on type 'DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>'.ts(2322)

1 个答案:

答案 0 :(得分:2)

ReadOnly是您需要使用的道具。确保O是大写字母。