| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 | 
							- <!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>
 
 
  |