我正在尝试在 tsx 文件中实现 antd 上传按钮功能,但由于某种原因,我遇到了以下 Typescript 错误。
我也为此创建了一个界面,但没有运气。请建议我在哪里做错了。谢谢
Type '{ children: Element; maxCount: number; }' is not assignable to type 'IntrinsicAttributes & UploadProps<any> & { children?: ReactNode; } & RefAttributes<any>'.
Property 'maxCount' does not exist on type 'IntrinsicAttributes & UploadProps<any> & { children?: ReactNode; } & RefAttributes<any>'
这是代码
interface IMyProps {
maxCount: number,
}
const AdminPage: React.FC<IMyProps> = ({maxCount}) => {
const [isModalVisible, setIsModalVisible] = useState(false);
const onFinish = (values:any) => {
console.log(values)
};
return (
<React.Fragment>
<div>
<Modal title="Create" visible={isModalVisible} footer={null} onCancel={()=>setIsModalVisible(false)}>
<Form layout="vertical" onFinish={onFinish}>
<Form.Item label="Upload" name="uploading" >
<Upload maxCount={1}> <---------------- GETTING ERROR HERE
<Button icon={<UploadOutlined />}>Click to Upload</Button>
</Upload>
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit">
Submit
</Button>
</Form.Item>
</Form>
</Modal>
</div>
</React.Fragment>
)
}
export default AdminPage;