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 });