直接上代码:
let arr = [1, 2, 3, 4, 2];
async function xxx(num) {
return 666 + num;
}
async function ttt() {
let res = await Promise.all(arr.map(async (item) => {
return await xxx(item);
}))
return res;
}
ttt().then(console.log)
[ 667, 668, 669, 670, 668 ]
参考老铁的方法自己试验后的:https://blog.csdn.net/hannah1116/article/details/86541680