From 7afb5795bffdb68fe2da6038ceb2d77737ea220f Mon Sep 17 00:00:00 2001 From: rex Date: Mon, 18 Nov 2019 20:42:01 +0800 Subject: [PATCH] fix(Uploader): fix multiple not work (#2329) fix #2327 --- example/pages/uploader/index.wxml | 2 ++ packages/uploader/index.ts | 36 ++++++++++--------------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/example/pages/uploader/index.wxml b/example/pages/uploader/index.wxml index 81651c3c..0997f38f 100644 --- a/example/pages/uploader/index.wxml +++ b/example/pages/uploader/index.wxml @@ -12,6 +12,7 @@ 9 ? 9 : newMaxCount) : 1, // 最多可以选择的数量,如果不支持多选则数量为1 sourceType: capture, // 选择图片的来源,相册还是相机 - success: res => { - resolve(res); - }, - fail: err => { - reject(err); - } + success: resolve, + fail: reject }); }); } else { @@ -117,18 +104,17 @@ VantComponent({ wx.chooseMessageFile({ count: multiple ? newMaxCount : 1, // 最多可以选择的数量,如果不支持多选则数量为1 type: 'file', - success(res) { - resolve(res); - }, - fail: err => { - reject(err); - } + success: resolve, + fail: reject }); }); } - chooseFile.then(res => { - const file: File | File[] = multiple ? res.tempFiles : res.tempFiles[0]; + chooseFile.then((res: + WechatMiniprogram.ChooseImageSuccessCallbackResult | + WechatMiniprogram.ChooseMessageFileSuccessCallbackResult + ) => { + const file = multiple ? res.tempFiles : res.tempFiles[0]; // 检查文件大小 if (file instanceof Array) { @@ -147,7 +133,7 @@ VantComponent({ this.$emit('before-read', { file, name, - callback: result => { + callback: (result: boolean) => { if (result) { // 开始上传 this.$emit('after-read', { file, name });