async function loadImgs(imgList, cb) {
let proList = [];
for (var i = 0; i < imgList.length; i++) {
let pro = await imgLoader(imgList[i], i);
proList.push(pro);
}
return Promise.all(proList)
.then(() => {
console.log("finish all");
cb();
return Promise.resolve();
})
}
async function imgLoader(url, num) {
return new Promise((resolve, reject) => {
console.log("request" + num);
setTimeout(resolve, 1000);
console.log("return" + num);
})
}
loadImgs(["xxx/a.png", "xxx/b.png"], function() {
console.log("开始干活");
})
console