| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 | 
							- <!DOCTYPE html>
 
- <html lang="en">
 
-   <head>
 
-     <meta charset="UTF-8" />
 
-     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 
-     <title>Document</title>
 
-   </head>
 
-   <body>
 
-     <script>
 
-       /**
 
-        * es6 => Promise => 回调地狱
 
-        * es7 => async await
 
-        * async 在函数前添加async 使函数变成异步函数
 
-        * await 不是说一定要和async一起使用  后面一般跟表达式 如何async一起使用的话  await后是微任务
 
-        */
 
-       //   console.log(2);
 
-       //   setTimeout(() => {
 
-       //     console.log(3);
 
-       //   }, 0);
 
-       //   async function fn1() {
 
-       //     throw new Error("报错")
 
-       //     // return '111';
 
-       //   }
 
-       //   fn1().then(()=>{
 
-       //     console.log(2)
 
-       //   })
 
-       //   fn1().catch(()=>{
 
-       //     console.log("3")
 
-       //   })
 
-       console.log(1);
 
-       function count(num) {
 
-         return new Promise((resolve, reject) => {
 
-           setTimeout(() => {
 
-           
 
-             resolve(num * 2);
 
-           }, 1000);
 
-         });
 
-       }
 
-       setTimeout(() => {
 
-         console.log(3);
 
-       }, 0);
 
-       async function fn2() {
 
-         try {
 
-           let total1 = await count(2);
 
-           let total2 = await count(20);
 
-           let total3 = await count(200);
 
-           console.log(total1, total2, total3);
 
-         } catch {
 
-           console.log("失败");
 
-         }
 
-       }
 
-       fn2();
 
-       console.log("完成");
 
-     </script>
 
-   </body>
 
- </html>
 
 
  |