export default {}
class GetNameClass {
private _fullName: string = "倪妮";
// 需求:我们就想要在外部进行修改 _fullName 那怎么办?
get fullName():string {
console.log("我是get方法");
return this._fullName;
}
set fullName(newName: string){
console.log("我是set方法");
this._fullName = newName;
}
}
let startname = new GetNameClass();
startname.fullName = "袁冰妍";
console.log(startname.fullName);
ts重点学习69-getter和setter笔记
最新推荐文章于 2024-05-07 08:42:10 发布