在beforeUpload事件中停止上载/处理蚂蚁设计上载组件

问题描述

我正在尝试使用ant-design上传图片。 这是我在社区中发现的一个例子。

Using customRequest in Ant design file upload

这是演示链接

https://stackblitz.com/edit/so-58128062-upload-progress-4gyng9

我正在尝试添加

  const beforeUpload = () => {
    return false; // STOP all actions including Upload and progres/preview
    //Using Hooks to update the state to the current filelist
    //filelist - [{uid: "-1",url:'Some url to image'}]
  };

阻止所有上传过程/预览操作。但这不起作用。

谢谢您的帮助

解决方法

是的,我找到了。

只需将onChange事件的默认列表设置为空,然后确定即可

  const handleOnChange = ({ file,fileList,event }) => {
     setDefaultFileList([]);
  };

如果您想要类似的行为,希望能帮助某人

demo