//定义一个异步函数 const foo1 = (i) => { return new Promise((resolve, reject) => { setTimeout(() => { console.log(I) resolve(i) }, 3000) }) } const arr = [1, 2, 3, 4, 5] async function a() { for (var i = 0; i < arr.length; i++) { await foo1(arr[i]) } } a()
标签:异步,arr,同步,const,resolve,循环,foo1 From: https://www.cnblogs.com/lzhflzjx/p/16791592.html