From c2a7f09e9e8dc1f9a2cbb90ce155b4e7ed73ff2d Mon Sep 17 00:00:00 2001 From: icssoa <615206459@qq.com> Date: Tue, 6 May 2025 11:03:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/upload/components/upload.vue | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/plugins/upload/components/upload.vue b/src/plugins/upload/components/upload.vue index caaffd8..5e58a93 100644 --- a/src/plugins/upload/components/upload.vue +++ b/src/plugins/upload/components/upload.vue @@ -334,6 +334,12 @@ async function onBeforeUpload(file: any, item?: Upload.Item) { return true; } + // 文件大小限制 + if (file.size / 1024 / 1024 >= limitSize) { + ElMessage.error(t('上传文件大小不能超过 {n}MB!', { n: limitSize })); + return false; + } + // 自定义上传事件 if (props.beforeUpload) { let r = props.beforeUpload(file, item, { next }); @@ -348,11 +354,6 @@ async function onBeforeUpload(file: any, item?: Upload.Item) { return r; } else { - if (file.size / 1024 / 1024 >= limitSize) { - ElMessage.error(t('上传文件大小不能超过 {n}MB!', { n: limitSize })); - return false; - } - return next(); } }