Ant Design 上传(Upload)组件报错:[antd: Upload] `value` is not a valid prop, do you mean `fileList`?

报错:
Warning: [antd: Upload] value is not a valid prop, do you mean fileList?
Uncaught TypeError: (fileList || []).forEach is not a function

错误原因:上传组件(Upload)写在标签内部
代码如下:
<Form.Item name="video" label="上传视频">
    <Upload customRequest={customRequest}>
       <Button icon={<UploadOutlined />}>上传视频</Button>
    </Upload>
</Form.Item>
解决方法:
<Form.Item
  name="video"
  // 下面两条必须存在
 valuePropName="fileList"
// 如果没有这一句会报错
Uncaught TypeError: (fileList || []).forEach is not a function
getValueFromEvent={normFile}
  label="上传视频"
> <Upload customRequest={customRequest}> <Button icon={<UploadOutlined />}>上传视频</Button> </Upload> </Form.Item>

 

参考文档:https://blog.csdn.net/weixin_47091394/article/details/117562144

 



posted @ 2022-02-25 13:44  Freya~  阅读(3321)  评论(0编辑  收藏  举报