(function() { /** * 抽象类 与其他类差别不大 abstract * 抽象类不是为了实例化对象 * 它是因继承而产生的类 */ abstract class Animal { name: string; constructor(name: string) { this.name = name; } // 抽象类中 方法没有具体内容 只有方法体 // 具体方法 需要在继承的子类中重写 abstract eat():void; } class A extends Animal { eat() { console.log(this.name + "吃了很多饭"); } } let a = new A("狗狗"); a.eat(); })()