- 派生类的构造器中必须调用super
- 类的参数属性,简写写法参数属性,parameter properties
// 类的参数属性
class Account{
readonly id:number;
owner:string;
private _balance:number;
nickname?:string;
constructor(id:number,owner:string,balance:number){
this.id = id;
this.owner = owner;
this._balance = balance;
}
}
将上述类的参数简写
class Account {
nickname?:string;
constructor(
public readonly id:number,
public owner: string,
private _balance: number
){}
}