ant-design-vue
ant-design-vue copied to clipboard
The upload control settings limit the number of uploaded files, but after multiple selection, the files that exceed the limit will still request the api to upload, although it is not displayed on the page
- [ ] I have searched the issues of this repository and believe that this is not a duplicate.
Version
3.2.3
Environment
not need
Reproduction link
Steps to reproduce
官方upload 限制文件个数那个demo就能复现
What is expected?
超出后的文件拦截下来 不要请求接口上传
What is actually happening?
超出后的文件依然请求接口上传了 只是页面上没显示
有办法限制超出后的文件不要上传么 现在超出的文件也会请求接口上传 这是不正常的, 官方文档里的demo能复现这个问题
需要自己处理 感觉可以内置处理下
const leftCount = computed(() => attrs.maxCount as number - fileList.value.length);
// 上传之前校验
const beforeUpload = (file: FileList[number], files: FileList) => {
// 校验文件数是否超出,超出部分直接丢弃
const index = files.findIndex(elem => elem === file);
if (index >= leftCount.value) {
return false
}
const size = file.size || 0;
if (!unref(accept).includes(file.type || '')) {
message.error(
t('page.upload_img_tip_type', {
name: file.name
})
);
return CUpload.LIST_IGNORE;
}
// 文件大小校验
const maxSize: number = (attrs.maxSize as number) || 200;
if (size > maxSize * UNIT) {
message.error(
t('page.upload_img_tip_size', {
size: (size / 1024).toFixed(0),
maxSize
})
);
return CUpload.LIST_IGNORE;
}
return true;
};
CUpload.LIST_IGNORE 这个怎么来的
import { message, Upload } from 'ant-design-vue'
CUpload.LIST_IGNORE 应该是Upload.LIST_IGNORE吧
import { message, Upload } from 'ant-design-vue'
CUpload.LIST_IGNORE 应该是Upload.LIST_IGNORE吧
yes
这是来自QQ邮箱的假期自动回复邮件。 您好,邮件已收到。记得常联系哦
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days
这是来自QQ邮箱的假期自动回复邮件。 您好,邮件已收到。记得常联系哦
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.