local存储在wp8错误 [英] localStorage on wp8 error

查看:88
本文介绍了local存储在wp8错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WP8 HTML / JS应用程序,我需要在本地存储上保存一些简单的数据。它应该是非常容易的事情,但它已经让我头痛。

I have a WP8 HTML/JS app and I need to save some simple data on the local storage. It should be something very easy, but it is giving my a headache already.

我试图以多种不同的方式调用 localStorage ,但它不起作用。我得到的错误信息是:
系统无法找到指定的文件。

I tried to call the localStorage in many different ways but it doesn't work. The error message I get is: The system cannot find the file specified.

奇怪的是, > sessionStorage似乎很好。至少我没有使用该对象的任何错误。

The strange part, is that the sessionStorage seems to be fine. At least I don't get any error using that object.

其他信息:
- 我称之为localStorage的方式是: localStorage.setItem(),window ['localStorage'],window.localStorage等他们都说同样的消息。
- 我正在开发一个Windows Phone HTML应用程序OS8。
- 我称之为localStorage的方法是$('#channels')。bind('pagebeforeshow',function(e,data){...}
- 项目中唯一的引用是.Net for Windows Phone和Windows Phone。
- 我包含的一些js libs是jQuery,jQuery mobile和ko。
- 我在WP8设备和模拟器上进行测试

Additional info: - The ways I called localStorage are: localStorage.setItem(), window['localStorage'], window.localStorage, etc. they all say the same message. - I am developing a Windows Phone HTML app OS8. - The method I call the localStorage is in $('#channels').bind('pagebeforeshow', function (e, data) {...} - The only references in the project are .Net for Windows Phone and Windows Phone. - Some of the js libs I included are jQuery, jQuery mobile and ko. - I am testing on both WP8 device and Emulator

我不想将phoneGap和任何其他已知的数据库用于设备,因为我不想让本地代码进行交互只是为了调用fetch并保存一些数据。

I prefer not to use phoneGap and any other known db for devices, since I wouldn't like to involve interaction with the native code just to make the call to fetch and save some data.

UPDATE 1:
在经常评论之后,我逐一调查了我的js refs。当我添加jqm 1.3分钟时出现问题。
所有js都与我的应用程序捆绑在一起。还有其他任何建议吗?

UPDATE 1: After thefrontender comment, I investigated one by one my js refs. The problem appear when I add the jqm 1.3 min. All js are bundled with my app. Any other suggestions?

$(function () {
        try {
            localStorage.setItem('aaa', 123);
            alert(localStorage.aaa);
        }
        catch (err) { alert(err.message) }
    });


推荐答案

如果你更换

alert(localStorage.aaa);

with

alert(localStorage.getItem('aaa');

这篇关于local存储在wp8错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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