TypeScript set和get
class Person {
constructor() {
}
private _name:string;
public get name():string{
return this._name;
}
public set name(name:string){//不能定义返回类型,如: ":void"
this._name = name;
}
}
class Person {
constructor() {
}
private _name:string;
public get name():string{
return this._name;
}
public set name(name:string){//不能定义返回类型,如: ":void"
this._name = name;
}
}