123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <!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>
- class Person{
- constructor(name){
- this.name = name
- }
- eat(){
- console.log(this,'吃')
- }
- //类方法 调用
- static say(){
- console.log('shuo')
- }
- }
- /* 继承 */
- class Coder extends Person {
- constructor(name,xx){
- super(name)
- this.xx = xx
- }
- }
- var p1 = new Person('zs')
- console.log(p1)
- p1.eat()
- Person.say()
- var c1 = new Coder('lisi','xxxx')
- console.log(c1)
- Coder.say()
- </script>
- </body>
- </html>
|