Laya本地存储对象,读取上来之后没有类方法了

**Laya本地存储对象,读取上来之后没有类方法了**
Object.create()
Object.create()方法创建一个新对象,使用现有的对象来提供新创建的对象的__proto__。 (请打开浏览器控制台以查看运行结果。)
private playerData:PlayerData;
public init():void{
if(Laya.LocalStorage.getJSON("123") == null){//玩家第一次登录
this.playerData = new PlayerData(123,"jiangbo",1,35);
Laya.LocalStorage.setJSON(this.playerData.uid+"",this.playerData);
}else{//以后登录 读取本地数据
this.playerData = Laya.LocalStorage.getJSON("123");
let tpl = new PlayerData();
this.playerData['__proto__'] = tpl['__proto__'];
}
console.log(this.playerData.getOld());
console.log(this.playerData.getUserName());
console.log(this.playerData.Level);

Laya.timer.loop(2000,this,this.changeData);
}
private changeData() {
this.playerData.level++;
Laya.LocalStorage.setJSON(this.playerData.uid+"",this.playerData);
}

原文地址:https://www.cnblogs.com/as3lib/p/14725689.html