function getTime(seconds){
            return new Promise(resolve=>{
                setTimeout(() => {
                    resolve(seconds)
                }, seconds);
            })
        }

         

        async function test(){
            let arr = [getTime(2000),getTime(300),getTime(1000)]
            for await (let x of arr){
                console.log(x); // 2000  300 1000 按顺序的
            }
         }

        test()

 

相关文章:

  • 2022-12-23
  • 2021-10-24
  • 2021-05-22
  • 2021-11-28
  • 2022-12-23
  • 2021-08-24
  • 2021-06-20
  • 2021-11-09
猜你喜欢
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2021-10-01
  • 2021-11-15
相关资源
相似解决方案