Upload组件在Form中使用,会处于受控状态,所以默认值如FileList的初始化需要通过Form的setFieldsValue方法来设
const [form] = Form.useForm();
form.setFieldsValue({
banner: [{ uid: uuid().toString(), name: imageURL, status: 'done', url: imageURL}],
})
<Form.Item
label="Banner图"
name="banner"
valuePropName="fileList"
getValueFromEvent={normFile}
>
<Upload
name="bannerUpload"
customRequest={uploadHandler}
>
<Button icon={<UploadOutlined />}>上传图片</Button>
</Upload>
</Form.Item>