十条请求并发那个,不知道我这样写对不对?或者思路是不是对的?平时都没接触过这种类似的问题,刚刚花了十几分钟写的,感觉要裂开。。 const promiseList = [] for (let i = 0; i < 10; i++) { promiseList.push(Promise.resolve(i)) } const doPromise = async (promiseList) => { let actionList = [] let num = 0 let pListLength = promiseList.length for (p in promiseList) { actionList.push(p) num += 1 pListLength -= 1 if (num === 3 || pListLength === 0) { await Promise.all(actionList).then(console.log) num = 0 actionList = [] } } } doPromise(promiseList)
点赞 评论

相关推荐

牛客网
牛客企业服务