| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 | 
							- <!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>
 
-     <!-- 
 
-         类:
 
-           定义:class 名字
 
-           constructor 定义构造函数初始化
 
-           extends 继承
 
-           super() 继承父级
 
-     -->
 
-     <script>
 
-         class Person {
 
-             constructor(color,toy) {
 
-                 this.color = color;
 
-                 this.toy = toy;
 
-             }
 
-             // 类的方法
 
-             play() {
 
-                 console.log("我喜欢"+this.color+this.toy)
 
-             }
 
-         }
 
-         let p1 = new Person('红色','气球')
 
-         console.log(p1)
 
-         p1.play()
 
-         // es6继承
 
-         class newPerson extends Person {
 
-             constructor(color,toy,color1,toy1) {
 
-                 super(color,toy)
 
-                 this.color1 = color1;
 
-                 this.toy1 = toy1;
 
-             }
 
-             play() {
 
-                 console.log("我喜欢"+this.color1+this.toy1)
 
-             }
 
-             sun() {
 
-                 console.log("天晴了")
 
-             }
 
-         }
 
-         let news = new newPerson('黄色','花','粉色','花瓶');
 
-         console.log(news)
 
-         news.play()
 
-         news.sun()
 
-     </script>
 
- </body>
 
- </html>
 
 
  |