【发布时间】:2019-12-12 09:43:43
【问题描述】:
如何使用 tsx 将对象传递给 reactjs 中的子组件。当我尝试这种方式时,我收到了这个错误。我可以在哪里声明类型?
Property 'value' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<ShipmentCard>
Cards.tsx
render() {
return (
<div>
{this.state.card.map((card: any) => (
<ShipmentCard key={card.id} value={card}/>
))}
</div>
);
}
完整的错误信息是:
键入'{键:任意;数据:任何; }' 不可分配给类型 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly'。属性“数据” 'IntrinsicAttributes & 类型不存在 IntrinsicClassAttributes & Readonly & Readonly'
【问题讨论】:
-
完整错误信息
Type '{ key: any; data: any; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<ShipmentCard> & Readonly<{}> & Readonly<{ children?: ReactNode; }>'. Property 'data' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<ShipmentCard> & Readonly<{}> & Readonly<{ children?: ReactNode; }>'
标签: reactjs components pass-data tsx