let Data = JSON.parse(cc.sys.localStorage.getItem(‘userData’));
这是开始的代码,先判断的Data是否为null,是的话储存初始数据,否的话就直接用
在浏览器调试通过了,第一次运行储存初始数据,再刷新就直接读之前的了
但是在开发者工具里报错:
gameThirdScriptError
Unexpected end of JSON input
SyntaxError: Unexpected end of JSON input
at JSON.parse ()
是我用错了吗,不能上来就localStorage.getItem()?