From 0da9f368b8d22a1c93842343671fffba3bf2ca0d Mon Sep 17 00:00:00 2001 From: zhangqi <2794379662@qq.com> Date: Tue, 8 Jun 2021 10:17:48 +0800 Subject: [PATCH] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Upload.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/Upload.vue b/src/components/Upload.vue index d540b6d..151260c 100644 --- a/src/components/Upload.vue +++ b/src/components/Upload.vue @@ -45,20 +45,24 @@ export default { const updateValue = value => { context.emit("update:fileId", value); // 传递的方法 }; - const beforeUpload = file => { - console.log(file); + const beforeUpload = (file, fileList) => { + console.log(file, fileList); const isValid = props.isPdf === true ? file.type === "application/pdf" : file.type === "image/jpeg" || file.type === "image/png"; if (!isValid) { message.error("只能上传受支持格式的文件"); + fileList.pop(); + return false; } const isLt2M = file.size / 1024 / 1024 < 2; if (!isLt2M) { message.error("文件大小超过2MB!"); + fileList.pop(); + return false; } - return isValid && isLt2M; + return true; }; const handleChange = info => { console.log(info.file.status, info.file, info.fileList);