在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
class People { private _name: string; age: number; print() { return this._name + ":" + this.age + ":"; } //加入封装,使外部可使用私有 get name():string{ return this._name; } set name(newName:string){ this._name=newName; //可加判断 if(newName =="aaa"){ }else{ } } } let h = new People(); // h.name ="aaa";//Property 'name' is private and only accessible within class 'People' //接口 h.name = "sss"; h.age = 19; alert(h.print());
|
请发表评论