Commit 0aa4df0d authored by 杨梦雪's avatar 杨梦雪

上传图片大小限制

parent 521853ce
......@@ -647,20 +647,20 @@ export default {
// 图片上传成功前钩子
beforeAvatarUpload(file) {
// console.log(file, "22");
console.log(file, "beforeImage");
const isJPG = file.type === "image/jpg";
const isPng = file.type === "image/png";
const isJPEG = file.type === "image/jpeg";
const isLt20M = file.size / 1024 / 1024 < 30;
if (file == null) {
const isLt10M = file.size / 1024 / 1024< 10;
// console.log(isLt10M)
if (!isJPG && !isPng && !isJPEG) {
this.$message.info("上传图片只能是 JPG,JPEG或png 格式!");
}
if (!isLt20M) {
this.$message.info("上传图片大小不能超过 20MB!");
if (!isLt10M) {
this.$message.info("上传图片大小不能超过 10MB!");
}
return (isJPG || isPng || isJPEG) && isLt20M;
}
return (isJPG || isPng || isJPEG) && isLt10M;
},
handlePictureCardPreview(file) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment