循环上传图片,上传时会一直等待而不是异步
img1----------10s
img2----------20s
img3----------30s
img4----------40s
for (let s of this.images) {
await this.myUploadFile(s, res)
}
myUploadFile(s, res) {
return new Promise((res1, rej) => {
console.log(s);
uni.uploadFile({
url: `${API_BASE_URL}/updateImage`,
filePath: s.url,
name: 'image',
header: {
'Content-Type': 'application/json',
token: this.$store.getters.token
},
formData: {
// token: this.$store.getters.token,
outsourcingId: res.data.outsourcingId
},
success: res => {
res1();
}
})
})
},