(function(){ class Animal{ name:string; constructor(name:string){ this.name=name; } sayHello(){ console.log('动物再叫---'); } } class Dog extends Animal { age:number; constructor(name:string,age:number){ super(name); this.age=age; } sayHello() { // super.sayHello(); console.log('汪汪汪!'); } } const dog=new Dog('旺财',18); dog.sayHello(); })();
标签:TypeScript,name,age,sayHello,super,string From: https://www.cnblogs.com/tanxwuwang/p/17075068.html