const banners = [ 'imgObj', 'imgObj', 'imgObj' ]
const bannersActions = _.map(banners, (item, index) => {
return this.batchUpdateImg(item, index)
})
batchUpdateImg(obj, index) {
return new Promise((resolve, reject) => {
upload.upload(obj.file) .then(result => {
resolve(result.url)
}).catch(() => {
reject(new Error(`${index}: failed to upload file`))
})
})
}
Promise.all(bannersActions).then(results => {
console.log('>>>>>>>>', results.url)
})
网友评论