随时随地使用 async/awsit

// 使用立即执行方法,就可以随便哪里都可以使用awsit方法了
(async () => {
      const res = await fn()
})();

function fn() {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
      resolve(true)
       }, 3000);
    });
  }

猜你喜欢

转载自blog.csdn.net/cen_cs/article/details/90080930