星五博客

localStorage保存bool布尔型的问题

localStorage保存boolean布尔型时,会保存成字符串,所以要按字符串进行处理,例如:

console.log(this.iShow);
localStorage.setItem("iShow",false);
this.iShow=localStorage.getItem("iShow")=="true"?true:false;
console.log(this.iShow);