beforeFileUpload(file,fileList){
let fileName = file.name;
let uid = file.uid
let pos = fileName.lastIndexOf(".");
let lastName = fileName.substring(pos, fileName.length);
console.log(lastName,lastName.toLowerCase());
if (
lastName.toLowerCase() !== ".pdf" &&
lastName.toLowerCase() !== ".doc"&&
lastName.toLowerCase() !== ".docx"&&
lastName.toLowerCase() !== ".zip"&&
lastName.toLowerCase() !== ".rar"&&
lastName.toLowerCase() !== ".xls"&&
lastName.toLowerCase() !== ".xlsx"
) {
this.$message.error("文件必须为.pdf .doc .docx .zip .rar .xls .xlsx类型");
this.$refs.uploadFile.clearFiles();
return false;
}
},`在这里插入代码片`
vue upload上传文件限制文件类型
最新推荐文章于 2024-09-25 15:51:39 发布