TypeScript 的新手,感觉它应该非常简单,但我对语法不太满意!
非常简单的组件:
import * as React from "react";
import ControlArea from "./ControlArea";
interface IControlAreaProps {
welcome?: any;
}
export class Layout extends React.Component<IControlAreaProps> {
public render() {
return (
<ControlArea welcome="This is the control area"/>
);
}
}
我收到 TS 错误 Property 'welcome' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<ControlArea> & Readonly<{ children?: ReactNode; }>...'.
任何指向正确方向的观点都将不胜感激。
最佳答案
你在这里的错误是你将界面添加到 Layout 组件,而你应该将它们添加到 ControlArea 组件
interface IControlAreaProps {
welcome?: any
}
export default class ControlArea extends React.Component<IControlAreaProps> {
// Your ControlArea code
}
关于javascript - React Typescript 属性在类型/IntrinsicAttributes 和 IntrinsicClassAttributes 上不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48890795/