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

上传图片大小限制

parent 521853ce
...@@ -647,20 +647,20 @@ export default { ...@@ -647,20 +647,20 @@ export default {
// 图片上传成功前钩子 // 图片上传成功前钩子
beforeAvatarUpload(file) { beforeAvatarUpload(file) {
// console.log(file, "22"); console.log(file, "beforeImage");
const isJPG = file.type === "image/jpg"; const isJPG = file.type === "image/jpg";
const isPng = file.type === "image/png"; const isPng = file.type === "image/png";
const isJPEG = file.type === "image/jpeg"; const isJPEG = file.type === "image/jpeg";
const isLt20M = file.size / 1024 / 1024 < 30; const isLt10M = file.size / 1024 / 1024< 10;
if (file == null) { // console.log(isLt10M)
if (!isJPG && !isPng && !isJPEG) { if (!isJPG && !isPng && !isJPEG) {
this.$message.info("上传图片只能是 JPG,JPEG或png 格式!"); this.$message.info("上传图片只能是 JPG,JPEG或png 格式!");
} }
if (!isLt20M) { if (!isLt10M) {
this.$message.info("上传图片大小不能超过 20MB!"); this.$message.info("上传图片大小不能超过 10MB!");
}
return (isJPG || isPng || isJPEG) && isLt20M;
} }
return (isJPG || isPng || isJPEG) && isLt10M;
}, },
handlePictureCardPreview(file) { 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