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 } } }