e 1 semana atrás
pai
commit
47712c9f2a
2 arquivos alterados com 81 adições e 3 exclusões
  1. 7 3
      4.js高级/18.proxy.html
  2. 74 0
      4.js高级/19.Promise.html

+ 7 - 3
4.js高级/18.proxy.html

@@ -22,11 +22,15 @@
                 console.log(prototype,'prototype')
                 return target;
             },
-            set() {
-
+            set(target,key,prototype) {
+                console.log(target,'target1')
+                console.log(key,'key1')
+                console.log(prototype,'prototype1')
             }
         });
-        console.log(vase.get.name,'打印')
+        vase.name = 'LiLi'
+        // console.log(vase.get.name,'打印')
+        console.log(vase.set,'set')
     </script>
 </body>
 </html>

+ 74 - 0
4.js高级/19.Promise.html

@@ -0,0 +1,74 @@
+<!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>
+    <!-- 
+        Promise:构造函数
+        执行方向:自上到下
+        同步执行
+        异步执行
+        状态:三种状态
+            成功 resolve/fulfilled
+            失败 reject
+            等待 pending
+        js执行顺序:
+            先同步 后异步(先微后宏)
+    -->
+    <script>
+        // var a = 1;
+        // console.log(a);
+        // new Promise((resolve,reject)=>{
+        //     // 执行的代码块
+        //     reject();
+        //     console.log(12)
+        // }).then(()=>{
+        //     // 执行成功的代码块
+        //     console.log(11)
+        // }).catch(()=>{
+        //     // 执行失败的代码块
+        //     console.log(14)
+        // }) 
+        // console.log(10)
+
+        let book1 = new Promise((resolve,reject)=>{
+            console.log(1);
+            reject();
+        })
+        let book2 = new Promise((resolve,reject)=>{
+            console.log(2);
+            reject();
+        })
+        let book3 = new Promise((resolve,reject)=>{
+            console.log(3);
+            reject();
+        })
+        // Promise.all() 判断多个Promise 当传入的都成立 则成立
+        // Promise.all([book1,book2,book3]).then(()=>{
+        //     console.log('成功')
+        // }).catch(()=>{
+        //     console.log('失败')
+        // })
+        // Promise.race() 判断多个Promise 当传入的第一个成立 则成立
+        // Promise.race([book1,book2,book3]).then(()=>{
+        //     console.log('成功')
+        // }).catch(()=>{
+        //     console.log('失败')
+        // })
+        Promise.allSettled([book1,book2,book3]).then(()=>{
+            console.log('成功')
+        }).catch(()=>{
+            console.log('失败')
+        })
+        // book.then(()=>{
+        //     console.log("1")
+        // })
+        // book.catch(()=>{
+        //     console.log("12")
+        // })
+    </script>
+</body>
+</html>