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;
    }
}
原文地址:https://www.cnblogs.com/kingBook/p/14087110.html