<List
header={<div>list</div>}
bordered={true}
dataSource={props.list}
renderItem={(item, index) => (<List.Item onClick={() => { props.handleItemDelete(index) }}>{item}</List.Item>)}
style={{ width: '386px', marginTop: '20px' }}
/>
<List
中提示
[ts]
不能将类型“{ header: Element; bordered: true; dataSource: any; renderItem: (item: any, index: any) => Element; style: { width: string; marginTop: string; }; }”分配给类型“IntrinsicAttributes & IntrinsicClassAttributes<List> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<ListProps>, "footer" | "header" | "id" | "size" | "className" | ... 8 more ... | "locale"> & Partial<...> & Partial<...>”。
类型“IntrinsicAttributes & IntrinsicClassAttributes<List> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<ListProps>, "footer" | "header" | "id" | "size" | "className" | ... 8 more ... | "locale"> & Partial<...> & Partial<...>”上不存在属性“style”。 [2322]
(alias) class List
import List
<List.Item
中提示
[ts]
不能将类型“{ children: any; onClick: () => void; }”分配给类型“IntrinsicAttributes & IntrinsicClassAttributes<Item> & Readonly<{ children?: ReactNode; }> & Readonly<ListItemProps>”。
类型“IntrinsicAttributes & IntrinsicClassAttributes<Item> & Readonly<{ children?: ReactNode; }> & Readonly<ListItemProps>”上不存在属性“onClick”。 [2322]
(alias) class List
import List
List只是用于数据的展示。
既然不支持onClick属性,你可以把事件定义在你传给List.Item子元素中。