【发布时间】:2022-02-14 13:24:16
【问题描述】:
必填字段不适用于 antd 设计组件。因此,表单提交以下代码:
<div className="col-md-12 text-center" style={{ backgroundColor: "#bdc5ff" }}>
<Form.Item rules={[{ required: true }]}>
<Form.Item name="dragger" valuePropName="fileList" noStyle rules={[{ required: true }]}>
<Upload.Dragger
onChange={(e) => handleInputChange("file", e.file)}
beforeUpload={() => false}
name="files"
accept=".apng,.avif,.gif,.jpg,.jpeg,.jfif,.pjpeg,.pjp,.png,.svg,.webp"
action=""
rules={[{ required: true }]}
>
<p className="ant-upload-drag-icon">
<InboxOutlined />
</p>
<p className="text-dark">Click or drag file to this area to upload</p>
<p className="text-muted">Support for PNG, JPG, GIF up to 10MB.</p>
</Upload.Dragger>
</Form.Item>
</Form.Item>
</div>
在这里的文档中https://ant.design/components/form/v3 这应该有效 我也在使用常规的 HTML 表单
【问题讨论】: