function resolveAfter2Seconds(x){
  return new Promise(resolve => {
    setTimeout(() => {
      resolve(x)
    }, 2000)
  });
}

async function f1() {
  var x = await resolveAfter2Seconds(10);
  console.log(x)
}

f1()

 来自慕课:https://www.imooc.com/video/16631

相关文章:

  • 2021-06-28
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 1970-01-01
猜你喜欢
  • 2022-01-13
  • 2021-10-03
  • 2022-12-23
  • 2021-06-28
  • 2021-07-20
  • 2022-12-23
  • 2021-08-17
相关资源
相似解决方案