let array = [[{'level':"赛程表1",'time':3000},{'level':"对阵图1",'time':8000},{'level':"小组积分赛1",'time':10000}],[{'level':"赛程表2",'time':5000},{'level':"对阵图2",'time':8000},{'level':"小组积分赛2",'time':10000}],[{'level':"赛程表3",'time':5000},{'level':"对阵图3",'time':6000},{'level':"小组积分赛3",'time':9000}]]
async function sleep(time) {
await new Promise((resolve,reject)=>{
setTimeout(() => {
// console.log(`等了${time}s`)
resolve()
}, time);
})
}
async function doSome(params) {
for (let x = 0; x < array.length; x++) {
const eleArr = array[x];
for (let y = 0; y < eleArr.length; y++) {
const ele = eleArr[y];
console.log(ele.level)
await sleep(ele.time)
if (x>=array.length-1 && y>=eleArr.length-1) {
doSome()
}
}
}
}
doSome()
网友评论