Cordova localstorage不坚持 [英] Cordova localstorage not persisting

查看:657
本文介绍了Cordova localstorage不坚持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Windows Phone 7 sdk和phonegap开发混合移动应用程序。使用Cordova本地存储我正在存储价值。存储的值不持久如果我关闭应用程序,并重新启动在Windows Phone模拟器。任何人使用本地存储或替代持久存储在Windows Phone手机共享的想法将是巨大的。

  window.localStorage.test =一些测试数据; 
console.log(window.localStorage.test)//打印结果但不持久


解决方案

我相信正确的语法是:

  window.localStorage.setItem测试,一些测试数据); 

console.log(window.localStorage.getItem(test));

分配属性出现才能工作,因为javascript允许您附加新属性

是否在执行之间关闭模拟器?模拟器在您关闭时清除其用户状态。


I am developing an Hybrid Mobile app using Windows Phone 7 sdk and phonegap. Using Cordova local storage I am storing value. The stored value does not persist If I close the app and launch again in windows phone emulator. Anybody used local storage or alternative persistant storage in windows phone shares idea would be great.

window.localStorage.test = "Some test data";
console.log(window.localStorage.test) //It prints result but does not persist

解决方案

I believe the correct syntax is:

window.localStorage.setItem("test", "Some test data");

console.log(window.localStorage.getItem("test"));

Assigning properties appears to work simply because javascript allows you to attach new properties to objects.

Original Answer Are you closing the emulator between executions? The emulator clears its user state when you close it.

这篇关于Cordova localstorage不坚持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆