:before-upload = "handleUpload"
// 上传限制格式
handleUpload(file) {
console.log(file);
const isIMG =
file.name.split('.')[file.name.split('.').length - 1] === 'jpg' ||
file.name.split('.')[file.name.split('.').length - 1] === 'jpeg' ||
file.name.split('.')[file.name.split('.').length - 1] === 'png' ||
file.name.split('.')[file.name.split('.').length - 1] === 'rar' ||
file.name.split('.')[file.name.split('.').length - 1] === 'zip' ||
file.name.split('.')[file.name.split('.').length - 1] === 'pdf' ||
file.name.split('.')[file.name.split('.').length - 1] === 'doc' ||
file.name.split('.')[file.name.split('.').length - 1] === 'docx'
console.log(isIMG);
//20M
const isLt = file.size / 20480000 <= 1
if (!isIMG) {
this.$message.error('上传文件只支持pdf,docx,doc,jpg,png,rar,zip格式!')
return false
}
if (!isLt) {
this.$message.error('上传文件大小不能超过20M!')
return false
}
return true
},
网友评论