点击查看【bilibili】

    1. class Person{
    2. private _name:string = ''
    3. public get name() : string {
    4. return this._name
    5. }
    6. public set name(v : string) {
    7. this._name = v;
    8. }
    9. }
    10. const person = new Person()
    11. console.log(person.name )
    12. person.name = 'xiaoming'
    13. console.log(person.name)