@445908669 写道:
var CharInfo1 = {
password: "",
nickname: "",
maxHisScore: 0,
maxHisKillCount: 0,
coin: 0,
skinVec: "",
curskin: 0,
headid: 0,
curLen: 0,
};CharInfo1.username = "username"; CharInfo1.nickname = "nickname"; CharInfo1.maxHisScore = 0; CharInfo1.maxHisKillCount = 0; CharInfo1.coin = 0; CharInfo1.curskin =0; CharInfo1.headid = 0; cc.sys.localStorage.setItem("cinfo0", JSON.stringify(CharInfo1));
切换场景后, cc.director.loadScene("ReadyGame");
var t = JSON.parse(cc.sys.localStorage.getItem("cinfo0"));
cc.log("++++++11+++++++++%s", t.username)浏览器中报错
Uncaught TypeError: Cannot read property 'username' of null在不切换场景的条件下是没问题的,只要换场景浏览器就报这个错
帖子: 2
参与者: 1