e 1 周之前
父節點
當前提交
82374352e1
共有 1 個文件被更改,包括 32 次插入0 次删除
  1. 32 0
      4.js高级/18.proxy.html

+ 32 - 0
4.js高级/18.proxy.html

@@ -0,0 +1,32 @@
+<!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>
+    <!-- 
+        Proxy 代理
+
+    -->
+    <script>
+        let obj = {
+            name:"Tom"
+        }
+        // 实例化对象
+        let vase =  new Proxy(obj,{
+            get(target,key,prototype) {
+                console.log(target,'target')
+                console.log(key,'key')
+                console.log(prototype,'prototype')
+                return target;
+            },
+            set() {
+
+            }
+        });
+        console.log(vase.get.name,'打印')
+    </script>
+</body>
+</html>