![](/img/trans.png)
[英]Property does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<DatePicker> & Readonly<{ children?: ReactNode; }> …'
[英]Refactoring React to Typescript causes error Property 'readOnly' does not exist on type 'IntrinsicAttributes & InputProps & { children?: ReactNode; }'
我正在使用Typescript重构一个应用程序。 除了这个简单的组件外,Everthing的进展顺利。 我正在使用来自material-ui
Input
。
import {Input} from "material-ui";
class Cp extends React.Component<any, any> {
render = () => <Input readOnly/>
}
Typescript编译器抱怨readOnly
属性,但它在JavaScript中运行良好。
TS2559: Type '{ readOnly: true; }' has no properties in common with type 'IntrinsicAttributes & InputProps & { children?: ReactNode; }'.
但是我可以在由Input
元素的props扩展的接口HTMLInputElement
看到属性readOnly
。
如何绕过这个错误?
readOnly不是输入组件的道具。 你试过这种方式吗?
<Input inputProps={{ readOnly: true }} />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.