添加上传图片文件验证
This commit is contained in:
@ -80,6 +80,10 @@ export default {
|
||||
this.dialogImageUrl = file.url;
|
||||
},
|
||||
beforeUpload(file) {
|
||||
if (file.type.indexOf("image/") == -1) {
|
||||
this.msgError("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。");
|
||||
return false
|
||||
}
|
||||
let _self = this;
|
||||
if (!this.useOss) {
|
||||
//不使用oss不需要获取策略
|
||||
|
@ -86,9 +86,11 @@
|
||||
<el-input
|
||||
placeholder="请输入"
|
||||
v-model="ruleForm.address"
|
||||
maxlength="25"
|
||||
maxlength="80"
|
||||
show-word-limit
|
||||
:disabled="check"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 3, maxRows: 4 }"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="登录手机号" prop="username">
|
||||
@ -456,3 +458,8 @@ export default {
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
/deep/.el-input__count {
|
||||
background-color: unset;
|
||||
}
|
||||
</style>
|
||||
|
@ -131,6 +131,7 @@
|
||||
:action="upload.url"
|
||||
:disabled="upload.isUploading"
|
||||
:on-progress="handleFileUploadProgress"
|
||||
:before-upload="beforeUpload"
|
||||
:on-success="handleFileSuccess"
|
||||
:auto-upload="false"
|
||||
drag
|
||||
@ -265,6 +266,14 @@ export default {
|
||||
// resetForm(formName) {
|
||||
// this.$refs[formName].resetFields();
|
||||
// }
|
||||
beforeUpload(file){
|
||||
const fileSuffix = file.name.substring(file.name.lastIndexOf(".") + 1);
|
||||
const whiteList = ["pdf", "doc", "docx", "xls", "xlsx"];
|
||||
if (whiteList.indexOf(fileSuffix.toLowerCase()) === -1) {
|
||||
this.msgError("上传文件只能是 pdf、doc、docx、xls、xlsx格式。");
|
||||
return false;
|
||||
}
|
||||
},
|
||||
// 文件上传中处理
|
||||
handleFileUploadProgress(event, file, fileList) {
|
||||
this.upload.isUploading = true;
|
||||
|
Reference in New Issue
Block a user