TypeScript 基本继承
本文向大家介绍TypeScript 基本继承,包括了TypeScript 基本继承的使用技巧和注意事项,需要的朋友参考一下
示例
class Car { public position: number = 0; protected speed: number = 42; move() { this.position+= this.speed; } } class SelfDrivingCar extends Car { move() { // 开始四处走动:-) super.move(); super.move(); } }
本示例说明如何Car使用extends关键字创建该类的非常简单的子类。的SelfDrivingCar类重写move()方法和用途使用基类FPGA实现super。