本文共 486 字,大约阅读时间需要 1 分钟。
class Person{ constructor(name,age){ //构造函数 默认存在 this.name = name; this.age = age; } sayHello(){//原型方法 console.log(this.name); } static foo(){ console.log("aa"); } } class Male extends Person{ constructor(name,age){ super(name,age); this.sexy = "male"; } sayHi(){ super.sayHello(); } static bar(){ super.foo(); } } //var person = new Person("john",20); //var male = new Male("tjm",23); //console.log(male.name,male.age,male.sexy); //male.sayHello(); //male.sayHi(); //person.sayHello();转载地址:http://fkchj.baihongyu.com/