localStorage sessionStorage用法
时间:2020-03-31 13:01:48
收藏:0
阅读:68
只能保存JSON字符串 不能保存字符串数组 所以
var storage = window.sessionStorage;
storage.setItem(‘user‘,JSON.stringify(result[‘data‘][‘permissions‘]));
取的时候
var storage = window.sessionStorage;
let _this = this;
setTimeout(function (){
let _theme = theme;
for(var i=0; i< JSON.parse(storage["user"]).length; i++){
if(JSON.parse(storage["user"]).indexOf(‘admin‘) !== -1){
_this.statusCards = _this.statusCardsByThemes[_theme.name];
}else{
_this.statusCards = _this.statusCardsByThemes[_theme.name].slice(1,2);
}
}
}, 200);
原文:https://www.cnblogs.com/zhanglanzuopin/p/12603094.html
评论(0)