uni.chooseImage({ count: 9, // 从相册选择 sourceType: ['album'], success: (res) => { this.fileList = res.tempFiles
//res.tempFilePaths是返回的图片数组file
循环调用获取图片
for (let i = 0; i < res.tempFilePaths.length; i++) { uni.uploadFile({ url: `${uni.$config.baseURL}/xcx/oss/upload`, file: i, filePath: res.tempFilePaths[i], name: "file", header: { // 自定义请求头 "Content-Type": "multipart/form-data" }, success: (uploadRes) => { let obj = JSON.parse(uploadRes.data) // // 给id列表添加图片ossid _this.imageIdsList.push(obj.data.ossId) // 给id列表添加图片ossid _this.imageList.push(obj.data.url) }, fail: (err) => { console.log("upload failed:", err); }, }) } } })
标签:chooseImage,data,file,res,uni,上传,tempFilePaths From: https://www.cnblogs.com/0722tian/p/18204134