From 81fa934a83562d28857b27bc53eae5318a46379e Mon Sep 17 00:00:00 2001 From: cl Date: Thu, 26 Aug 2021 14:00:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=89=87=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mall4v/src/components/mul-pic-upload/index.vue | 6 ++++++ mall4v/src/components/pic-upload/index.vue | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/mall4v/src/components/mul-pic-upload/index.vue b/mall4v/src/components/mul-pic-upload/index.vue index b612d75..1c6177b 100644 --- a/mall4v/src/components/mul-pic-upload/index.vue +++ b/mall4v/src/components/mul-pic-upload/index.vue @@ -55,11 +55,17 @@ }, // 限制图片上传大小 beforeAvatarUpload (file) { + const isJPG = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/gif' || file.type === 'image/jpg' + if (!isJPG) { + this.$message.error('上传图片只能是jpeg/jpg/png/gif 格式!') + } const isLt2M = file.size / 1024 / 1024 < 2 if (!isLt2M) { this.$message.error('上传头像图片大小不能超过 2MB!') + this.$message.error('上传图片大小不能超过 2MB!') } return isLt2M + return isLt2M && isJPG }, handleRemove (file, fileList) { let pics = fileList.map(file => { diff --git a/mall4v/src/components/pic-upload/index.vue b/mall4v/src/components/pic-upload/index.vue index 53d5de3..6b255b4 100644 --- a/mall4v/src/components/pic-upload/index.vue +++ b/mall4v/src/components/pic-upload/index.vue @@ -34,10 +34,15 @@ // 限制图片上传大小 beforeAvatarUpload (file) { const isLt2M = file.size / 1024 / 1024 < 2 + const isJPG = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/gif' || file.type === 'image/jpg' + if (!isJPG) { + this.$message.error('上传图片只能是jpeg/jpg/png/gif 格式!') + } if (!isLt2M) { this.$message.error('上传图片大小不能超过 2MB!') } return isLt2M + return isLt2M && isJPG } } }