From e33c1fb937b3c43c82d8f31e338d99a995d1a25a Mon Sep 17 00:00:00 2001 From: zjl Date: Mon, 23 Dec 2024 13:39:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=9C=80=E5=A4=A7=E5=85=81?= =?UTF-8?q?=E8=AE=B8=E4=B8=8A=E4=BC=A0=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Upload/Images.vue | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/components/Upload/Images.vue b/src/components/Upload/Images.vue index 2062ab1..0fda733 100644 --- a/src/components/Upload/Images.vue +++ b/src/components/Upload/Images.vue @@ -120,13 +120,9 @@ const handleHttpUpload = async (options) => { loading.value = true; try { - if (props.limit && props.fileList.length >= props.limit) { - notification.warning({ - message: '温馨提示', - description: `最多支持上传${props.limit}张`, - }); - return false; - } + // 设置允许做大上传张数验证 + onExceed(); + // 上传文件 const formData = new FormData(); formData.append('file', options.file); formData.append('name', props.name); @@ -195,13 +191,9 @@ let filePath = props.name + '/' + year + '/' + month + '/' + day + '/' + fileName; loading.value = true; try { - if (props.limit && props.fileList.length >= props.limit) { - notification.warning({ - message: '温馨提示', - description: `最多支持上传${props.limit}张`, - }); - return false; - } + // 设置允许做大上传张数验证 + onExceed(); + // 设置请求头 const headers = { 'Access-Control-Allow-Origin': '*', }; @@ -313,11 +305,12 @@ * 设置最大允许上传张数 */ const onExceed = () => { - if (props.limit) { + if (props.limit && props.fileList.length >= props.limit) { notification.warning({ message: '温馨提示', description: `最多支持上传${props.limit}张`, }); + return false; } };