文件上传组件添加数量限制属性

This commit is contained in:
RuoYi 2021-07-08 15:49:04 +08:00
parent e963a86b15
commit e259093e01
1 changed files with 11 additions and 0 deletions

View File

@ -4,7 +4,9 @@
:action="uploadFileUrl"
:before-upload="handleBeforeUpload"
:file-list="fileList"
:limit="limit"
:on-error="handleUploadError"
:on-exceed="handleExceed"
:on-success="handleUploadSuccess"
:show-file-list="false"
:headers="headers"
@ -44,6 +46,11 @@ export default {
props: {
//
value: [String, Object, Array],
//
limit: {
type: Number,
default: 5,
},
// (MB)
fileSize: {
type: Number,
@ -129,6 +136,10 @@ export default {
}
return true;
},
//
handleExceed() {
this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`);
},
//
handleUploadError(err) {
this.$message.error("上传失败, 请重试");