ant-design / pro-components

🏆 Use Ant Design like a Pro!
https://pro-components.antdigital.dev
MIT License
4.14k stars 1.32k forks source link

ProFormUploadButton 设置 beforeUplodate 返回false,还是上传 #7677

Open ycshill opened 10 months ago

ycshill commented 10 months ago

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

🐛 bug 描述

📷 复现步骤

🏞 期望结果

💻 复现代码

© 版本信息

"antd": "4.24.8"

"@ant-design/pro-components": "2.6.2",

🚑 其他信息

ycshill commented 10 months ago

const beforeUpload = (file: RcFile, _: RcFile[]) => { const isSizeValid = file.size / 1024 / 1024 < 1;

if (!isSizeValid) {
  formRef.current?.setFieldsValue({
    descImgUrl: [],
  });
  message.error('只允许上传大小为1MB以内的图片');
}

return isSizeValid || Upload.LIST_IGNORE;

}; 用了 Upload.LIST_IGNORE 也不行

ATacoo commented 4 months ago

我也遇到了这个问题 现在解决了嘛

TaoTao2deng commented 4 weeks ago

解决了吗 ?我也碰到了这个问题

Deja-vuuu commented 6 hours ago

这样写没问题

 <ProFormUploadDragger
                    required
                    max={1}
                    width="sm"
                    label="Excel文件"
                    name="upload"
                    description=""
                    accept={'.xlsx,.xls,.xlsm,.csv'}
                    style={{ width: '80%' }}
                    fieldProps={{
                        beforeUpload(file, fileList) {
                            return false;
                        },
                    }}
                />