18.proxy.html 695 B

1234567891011121314151617181920212223242526272829303132
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <!--
  10. Proxy 代理
  11. -->
  12. <script>
  13. let obj = {
  14. name:"Tom"
  15. }
  16. // 实例化对象
  17. let vase = new Proxy(obj,{
  18. get(target,key,prototype) {
  19. console.log(target,'target')
  20. console.log(key,'key')
  21. console.log(prototype,'prototype')
  22. return target;
  23. },
  24. set() {
  25. }
  26. });
  27. console.log(vase.get.name,'打印')
  28. </script>
  29. </body>
  30. </html>