zsydgithub 1 ano atrás
pai
commit
f923b34b9c
4 arquivos alterados com 169 adições e 0 exclusões
  1. 39 0
      1.html
  2. 42 0
      111/3.html
  3. 61 0
      111/4.html
  4. 27 0
      es6/20_proxy.html

+ 39 - 0
1.html

@@ -0,0 +1,39 @@
+<!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>
+    const App = ()=>{
+      const parent = useRef<HTMLDivElement>(null)
+      const child = useRef<HTMLDivElement>(null)
+    }
+    useEffect(()=>{
+      parent.current.addEventListener('click',(e)=>{
+        console.log('dom parent')
+      })
+      child.current.addEventListener('click',(e)=>{
+        console.log('dom child')
+      })
+      document.addEventListener('click',(e)=>{
+        console.log('document')
+      })
+    },[])
+    const onParentClick = ()=>{
+      console.log('react parent')
+    }
+    const onChildClick = ()=>{
+      console.log('react child')
+    }
+    return{
+      <div ref={parent} onClick = {onParentClick}>
+        <div ref= {child} onClick = {onChildClick}>
+      </div>
+    }
+  </script> 
+</body>
+</html>

+ 42 - 0
111/3.html

@@ -0,0 +1,42 @@
+<!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()
+      setTimeout(function () {
+        console.log('setTimeout1')
+      }, 0)
+    }
+    async function async2() {
+      setTimeout(function () {
+        console.log('setTimeout2')
+      }, 0)
+    }
+    console.log('script start')
+    setTimeout(function () {
+      console.log('setTimeout3')
+    }, 0)
+    async1()  			
+    new Promise(function (r, j) {
+      console.log('Promise1')
+      r()
+    }).then(function () {
+      console.log('Promise2')
+    })
+    console.log('script end')
+    
+
+  </script>
+</body>
+
+</html>

+ 61 - 0
111/4.html

@@ -0,0 +1,61 @@
+<!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>
+    /* const obj = {
+      a:4,
+      print: ()=>{
+        console.log(this.a)
+      },
+      eat: function(){
+        console.log(this.a)
+      }
+    }
+    console.log(obj)
+    obj.print()
+    obj.eat() */
+
+
+
+    /* var a = 5
+    const obj = {
+      a: 6,
+      print: ()=>{
+        console.log(this.a)
+      }
+    }
+    obj.print.call({a:7}) */
+    //5
+
+
+
+    function Person(){
+      this.a = 8
+      this.print = function(){
+        console.log(this.a)
+      }
+      return{
+        a: 9
+      }
+    }
+    const p = new Person()
+    console.log(Person)
+    console.log(p.a)
+    console.log(p.print)
+    // 8 8
+    // 8 8
+    // 9 9 
+    // 9 8 
+    // 9 9 
+    // 8 9
+    // 8 9 
+    // 9 8
+  </script>
+</body>
+</html>

+ 27 - 0
es6/20_proxy.html

@@ -0,0 +1,27 @@
+<!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>
+    var obj = {
+      name: 'zs'
+    }
+    var a = new Proxy(obj,{
+      get(target,key,property){
+        console.log(target,key,property)
+      },
+      set(target,key,value){
+        console.log(target,key,value)
+        return target[key] = value
+      }
+    })
+    a.name = 'lisi'
+    console.log(a.get)
+  </script>
+</body>
+</html>