zsydgithub 1 рік тому
батько
коміт
c153a63c5f
3 змінених файлів з 78 додано та 0 видалено
  1. 34 0
      111/1.html
  2. 44 0
      111/2.html
  3. 0 0
      111/3.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