zl程序教程

您现在的位置是:首页 >  前端

当前栏目

TypeScript set和get

2023-09-27 14:25:33 时间
class Person {
    constructor() {
    }

    private _name:string;

    public get name():string{
        return this._name;
    }

    public set name(name:string){//不能定义返回类型,如: ":void"
        this._name = name;
    }
}