美文网首页
JavaScript 利用 async await 实现 sle

JavaScript 利用 async await 实现 sle

作者: 瘾_95f1 | 来源:发表于2019-08-12 15:04 被阅读0次
    const sleep = (timeountMS) => new Promise((resolve) => {
      setTimeout(resolve, timeountMS);
    });
    
    (async () => {
      console.log('11111111, ' + new Date());
      await sleep(2000);
      console.log('22222222, ' + new Date());
      await sleep(2000);
      console.log('33333333, ' + new Date());
    })();
    

    相关文章

      网友评论

          本文标题:JavaScript 利用 async await 实现 sle

          本文链接:https://www.haomeiwen.com/subject/stjujctx.html