e 11 сар өмнө
parent
commit
2869e015a1

+ 54 - 0
es6/10.es6类.html

@@ -0,0 +1,54 @@
+<!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>
+    <script>
+        // 类 class声明类
+        class Person {
+            // 1.构造器 属性
+            constructor(name,age){
+                this.name = name;
+                this.age = age;
+            }
+            // 2.方法
+            say() {
+                console.log("hello")
+            }
+            // static 类方法
+            static hello() {
+                console.log("你好啊");
+            }
+        }
+        // 继承类
+        // child要继承person中的属性及方法
+        class Child extends Person {
+            constructor(name,age,aaa,bbb) {
+                // super() 继承父类
+                super(name,age);
+                this.aaa = aaa;
+                this.bbb = bbb;
+            }
+            hi() {
+                console.log("hi")
+            }
+        }
+
+        // 调用
+        // 实例化对象
+        let per = new Person("John",20)
+        console.log(per.name,per.age);
+        per.say();
+        // per.hello()
+        Person.hello()
+
+        let children = new Child("Lucy",10,11,22);
+        console.log(children.name,children.age,children.aaa,children.bbb);
+        children.say();
+        children.hi()
+    </script>
+</body>
+</html>

+ 25 - 0
es6/11.symbol.html

@@ -0,0 +1,25 @@
+<!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>
+    <script>
+        /**
+         * 数据类型:
+         * null undefined boolean string number object
+         * symbol 独一无二的
+         * 
+         */
+         var a = Symbol();
+         console.log(a);
+
+         var a1 = Symbol(1);
+         var a2 = Symbol(1);
+        //  就算传入的值相同 也是false
+         console.log(a1 === a2);
+    </script>
+</body>
+</html>

+ 42 - 0
es6/9.原型.html

@@ -0,0 +1,42 @@
+<!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>
+    <script>
+        /**
+         * 所有构造函数都有个phototype属性  这个属性是该函数的圆形队形
+         * 原型对象的特点:
+         *     
+         * 属性 构造函数里
+         * 方法 原型对象下
+        */
+       function Person(name,age) {
+            this.name = name;
+            this.age = age;
+            // console.log(this,this.name,this.age);
+       }
+       Person.prototype.eat = function() {
+        console.log("吃饭");
+       }
+        let aa =  new Person("孙悟空",10);
+    //    console.log(Person.prototype.constructor)
+    //    aa.eat();
+       /**
+        * 子类继承父类
+        * 1.在子类的 构造函数里 调用父类.call()方法
+        * 2.子类的原型对象 = new 父类的继承方法
+       */
+       function Child(name,age) {
+         Person.call(this,name,age);
+       }
+       Child.prototype = new Person();
+        //实例化
+       let bb = new Child("猪八戒",20);
+       console.log(bb.name,bb.age);
+    </script>
+</body>
+</html>