实例名称:多图上传进度提示
适用范围:微信小程序 基础库1.0.1及以上
page.js中书写代码片段如下
Page({
data:{
src:''
},
//上传事件
upImage(e){
wx.chooseImage({
success (res) {
const tempFilePaths = res.tempFilePaths
for(var i =1;i<=tempFilePaths.length;i++){
wx.showLoading({
title:'上传中'+i+'/'+tempFilePaths.length,
mask:true
})
wx.uploadFile({
url: '你的线上文件接收服务地址/upload',
filePath: tempFilePaths[i],
name: 'file',
formData: {},
success (res){
wx.hideLoading();
console.log(res);//这块就接收你后台返回过来的图片数据
}
})
}
}
})
}
})
说明:wxml中用bindTap事件进行绑定即可。