.net 长时间没有操作页面 导致了localStorage消失,然后一些用到localStorage的页面,因为localStorage里的内容消失了,是undefined,而在使用localStorage之前要json序列化一下,才能用里面的数据,而json是不能序列化undefined,使用页面会报错,这么解决呢?
//先判断数据是否为undefined,再去序列化
if(typeof(info) !== 'undefined')
const jsonText = JSON.stringify(info)