zsydgithub 1 éve
szülő
commit
b0b39ded9d
4 módosított fájl, 82 hozzáadás és 4 törlés
  1. 34 0
      111/1.html
  2. 44 0
      111/2.html
  3. 0 0
      111/3.html
  4. 4 4
      es6/19_async await.html

+ 34 - 0
111/1.html

@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+  <meta charset="UTF-8">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>Document</title>
+</head>
+
+<body>
+  <script>
+    async function async1() {
+      console.log('async1 start');
+      await async2();
+      console.log('async1 end');
+    }
+    async function async2() {
+      console.log('async2');
+    }
+    console.log('script start')
+    async1();
+    new Promise(function (resolve) {
+      console.log('promise1');
+      resolve();
+    }).then(function () {
+      console.log('promise2');
+    });
+    console.log('script end')
+    //sc start => asy1 start => asy2 => p1 => sc end => asy1 end => p2
+  </script>
+</body>
+
+</html>

+ 44 - 0
111/2.html

@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+  <meta charset="UTF-8">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>Document</title>
+</head>
+
+<body>
+  <script>
+    // 说出下面代码的输出
+    async function async1() {
+      console.log('async1 start');
+      await async2();
+      console.log('async1 end');
+    }
+    async function async2() {
+      console.log('async2');
+      /* return new Promise((resolve, reiejct) => {
+        resolve()
+      }) */
+      /* Promise1.then((Promise2)=>{
+        Promise2.then(()=>{
+          console.log()
+        })
+      }) */
+    }
+    console.log('script start')
+    async1();
+    new Promise(function (resolve) {
+      console.log('promise1');
+      resolve();
+    }).then(function () {
+      console.log('promise2');
+    });
+    console.log('script end')
+     //sc start => asy1 start => asy2 => p1 => sc end =>  p2 => asy1 end 
+
+  </script>
+</body>
+
+</html>

+ 0 - 0
111/3.html


+ 4 - 4
es6/19_async await.html

@@ -83,7 +83,7 @@
     fn2() */
 
 
-    /* async function fn1(){
+    async function fn1(){
       console.log(333)
       await fn2()
       console.log(111)
@@ -92,11 +92,11 @@
       throw new Error('rejected')
     }
     fn1()
-    console.log(2222) */
+    console.log(2222)
 
 
 
-    async function fn1(){
+    /* async function fn1(){
       console.log(1)
       await fn2()
       console.log(2)
@@ -115,7 +115,7 @@
       },0)
     }
     fn1()
-    console.log(7)
+    console.log(7) */
     //1475263
     //1472563
   </script>