添加上传图片文件的验证

This commit is contained in:
熊丽君
2021-10-20 09:28:09 +08:00
parent 9b416ac846
commit f0b9b83d4c
3 changed files with 12 additions and 2 deletions

View File

@ -96,6 +96,10 @@ export default {
this.dialogVisible = true;
},
beforeUpload(file) {
if (file.type.indexOf('image/') == -1) {
this.msgError('文件格式错误,请上传图片类型,如JPGPNG后缀的文件。');
return false;
}
// const fileSuffix = file.name.substring(file.name.lastIndexOf('.') + 1);
// const whiteList = ['pdf', 'doc', 'docx', 'xls', 'xlsx'];
// if (whiteList.indexOf(fileSuffix) === -1) {