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>