before-upload 验证中 使用 return false 无法中断上传
部分验证
// 以下验证只允许上传图片
const isJPG = file.type === "image/jpg";
const isJPEG = file.type === "image/jpeg";
const isPNG = file.type === "image/png";
const isWebp = file.type === "image/webp";
const isLt50M = file.size / 1024 / 1024 < 50; //限制大小
if (!isLt50M) {
this.$message.warning("上传文件大小不能超过 50MB!");
return false;
}
if (!isJPG && !isJPEG && !isPNG && !isWebp) {
var p = /image\/\w+/.test(file.type) //防止报type类型未识别的错误
if (!p) {
this.$message.error('上传文件必须是JPG/JPEG/PNG/WEBP 格式!')
if (