【问题标题】:Stop upload/process ant-design Upload component on beforeUpload event在 beforeUpload 事件上停止上传/处理 ant-design Upload 组件
【发布时间】:2021-01-31 15:51:49
【问题描述】:

我正在尝试使用 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'}]
  };

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

感谢您的帮助

【问题讨论】:

    标签: javascript reactjs antd ant-design-pro


    【解决方案1】:

    是的,我找到了。

    只需将 onChange 事件的默认列表设置为空即可

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

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

    demo

    【讨论】:

      猜你喜欢
      • 2022-01-22
      • 2021-07-03
      • 1970-01-01
      • 2013-11-12
      • 2021-02-06
      • 2023-01-20
      • 2021-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多