// 文件上传 上传前检测
handleBeforeUpload(file) {
// console.log(file);
const isFileAllow1 = [
'image/jpeg',
'image/bmp',
'image/gif',
'image/png',
'image/jpg',
].includes(file.type);
const isFileAllow2 = [
'Video Transport Stream File', // ts
'TypeScript File', // ts
'Qt Translation Source File', // ts
'video/x-msvideo', // avi
'video/mp4', // mp4
'',
''
].includes(file.type);
let isLt = true;
let size = 10
let type = '附件'
if (isFileAllow1) {
isLt = file.size / 1024 / 1024 <= 2;
size = 2
type = '图片'
} else if (isFileAllow2) {
isLt = file.size / 1024 / 1024 <= 500;
size = 500
type = '视频122'
}
if (!isLt) {
this.$message.error('上传'+ type +'大小不能超过' + size + 'MB!');
return false;
}
return isLt;
},
console