localStorage sessionStorage用法

只能保存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);   
 
 

猜你喜欢

转载自www.cnblogs.com/zhanglanzuopin/p/12603094.html