zoukankan      html  css  js  c++  java
  • 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);
    }

  • 相关阅读:
    04-Bootstrap的插件
    03-Bootstrap学习
    02-移动端单位介绍
    01 响应式页面-@media介绍,
    14-jQuery补充
    13-jQuery的ajax
    12-事件委托(事件代理)
    11-jQuery的事件绑定和解绑
    10-事件对象
    09-JS的事件流的概念(重点)
  • 原文地址:https://www.cnblogs.com/as3lib/p/14725689.html
Copyright © 2011-2022 走看看