【发布时间】:2018-04-23 02:53:44
【问题描述】:
您好,
在我的代码中,我尝试了写在本机存储插件页面上的代码:Native Storage
import { NativeStorage } from '@ionic-native/native-storage';
constructor(private nativeStorage: NativeStorage) { }
...
this.nativeStorage.setItem('myitem', {property: 'value', anotherProperty: 'anotherValue'})
.then(
() => console.log('Stored item!'),
error => console.error('Error storing item', error)
);
this.nativeStorage.getItem('myitem')
.then(
data => console.log(data),
error => console.error(error)
);
当我启动我的 android 模拟器设备时,控制台会发回这个:
[00:02:01] console.log: Stored item!
[00:02:01] console.log: [object Object]
我想找到一种解决方案来读取存储的信息。因为我想使用存储在本机存储中的值在外部页面上创建条件,但我不能。示例“如果存储在名称 Vibrator 的本机存储中的值 == 为 true,则我们启动此函数”。我正在寻找读取值的方法。你能帮帮我吗?
谢谢
【问题讨论】:
标签: angular typescript cordova-plugins ionic3 cordova-nativestorage