From e259093e01a924469ed599fd3311c5b2fc04d49b Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: 星期四, 08 七月 2021 15:49:04 +0800 Subject: [PATCH] 文件上传组件添加数量限制属性 --- ruoyi-ui/src/components/FileUpload/index.vue | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/ruoyi-ui/src/components/FileUpload/index.vue b/ruoyi-ui/src/components/FileUpload/index.vue index 649e077..6e7992a 100644 --- a/ruoyi-ui/src/components/FileUpload/index.vue +++ b/ruoyi-ui/src/components/FileUpload/index.vue @@ -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 @@ props: { // 鍊� value: [String, Object, Array], + // 鏁伴噺闄愬埗 + limit: { + type: Number, + default: 5, + }, // 澶у皬闄愬埗(MB) fileSize: { type: Number, @@ -129,6 +136,10 @@ } return true; }, + // 鏂囦欢涓暟瓒呭嚭 + handleExceed() { + this.$message.error(`涓婁紶鏂囦欢鏁伴噺涓嶈兘瓒呰繃 ${this.limit} 涓�!`); + }, // 涓婁紶澶辫触 handleUploadError(err) { this.$message.error("涓婁紶澶辫触, 璇烽噸璇�"); -- Gitblit v1.9.3