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

 




免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM