ant design upload组件的beforeUpload阻止默认上传行为

  const onImportExcel = (file) => {
    return new Promise(async (resolve, reject) => {
 
      ...  //要执行的语句
        return reject(false);  //加上这个就会阻止默认上传
     
    });
  };
    <Upload
          name="file"
          className="avatar-uploader"
          showUploadList={false}
          beforeUpload={onImportExcel}
          accept=".xlsx,.xls,.xlt"
        >
          <Button type="primary" icon={<DownloadOutlined />}>
            导入
          </Button>
        </Upload>

  

上一篇:sqlmap的基本使用


下一篇:antd动态tree 自定义样式