ProFormUploadButton Upload.LIST_IGNORE 不生效?-灵析社区

饼干爱折腾

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; }; 还是会有图片显示,怎么能不显示fileList 呀啊!

阅读量:342

点赞量:12

问AI
const beforeUpload = (file: RcFile, _: RcFile[]) => { return new Promise((resolve, reject) => { const isSizeValid = file.size / 1024 / 1024 < 1; if (!isSizeValid) { message.error('只允许上传大小为1MB以内的图片'); reject(new Error('文件太大')); } else { resolve(file); } }); };