简体   繁体   English

Windows Phone phonegap / cordova localstorage不保存数据

[英]Windows Phone phonegap/cordova localstorage not saving data

I have problem with localStorage in phonegap. 我在phonegap中遇到localStorage的问题。 There are two types of notation in localStorage: localStorage中有两种表示法:

1. localStorage.setItem["key", "value"]/localStorage.getItem["key"] (not working for me) 1. localStorage.setItem [“key”,“value”] / localStorage.getItem [“key”](不适合我)
2. localStorage.key (works fine, but not saving data, after relaunch application) 2. localStorage.key(在重新启动应用程序后工作正常,但不保存数据)

are you using the square brackets? 你使用方括号吗? You´re setting up an array instead of calling a function. 你设置一个数组而不是调用一个函数。

try this: 尝试这个:

localStorage.setItem("key", "value");

//get the value
localStorage.getItem("key");

My personal suggestion would be don't use the local storage.Its not good for the long run,as it is almost deprecated and has a limitation in the storage size. 个人的建议是不要使用本地存储。从长远来看这不好,因为它几乎已被弃用并且存储大小有限。

Use a plugin and adapt SQLITE database or anything that would not have restriction on the size of storage. 使用插件并调整SQLITE数据库或任何对存储大小没有限制的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM