【发布时间】:2016-09-11 07:55:54
【问题描述】:
我正在尝试检索 localStorage 值;但是,我无法获得任何价值,并且我的日志如下所示:
日志是:{}
这是我目前的代码:
import {Storage, LocalStorage} from 'ionic-angular';
//I am storing here
this.local = new Storage(LocalStorage);
this.local.set('options', 'op2');
//In the chrome developer tools, I can see that the value was stored successfully in localStorage
//I can't see anything, when trying to retrieve the stored value
console.log('log is : '+ JSON.stringify(this.local.get('options')));
【问题讨论】:
-
这里的LocalStorage和Storage是什么?
-
LocalStorage 使用以下
import Storage, LocalStorage} from 'ionic-angular';导入 -
那么使用 setItem(...) 而不是 set(..),当然还有 getItem(..)。
-
嗯,在这种情况下,它与
set()完全相同,是 ionic2 框架的一部分 -
你为什么要开始一个新问题而不是在这里继续你自己的问题:stackoverflow.com/questions/37229203/…?
标签: javascript ionic2