我明白了
TypeError:表达式'localStorage'[null]的结果不是对象
当我尝试访问 Symbian/Phonegap 应用程序上的 localStorage 时,这与之前发生的错误有关:
TypeError:表达式“window.widget.preferenceForKey”[undefined] 的结果不是函数。发生在一行中
var pref = window.widget.preferenceForKey(Storage.PREFERENCE_KEY);
function Storage() {
this.available = true;
this.serialized = null;
this.items = null;
if (!window.widget) {
this.available = false;
return;
}
var pref = window.widget.preferenceForKey(Storage.PREFERENCE_KEY);
//storage not yet created
if (pref == "undefined" || pref == undefined) {
this.length = 0;
this.serialized = "({})";
this.items = {};
window.widget.setPreferenceForKey(this.serialized, Storage.PREFERENCE_KEY);
} else {
this.serialized = pref;'({"store_test": { "key": "store_test", "data": "asdfasdfs" },})';
this.items = eval(this.serialized);
}
}
看来我需要解决本地存储我不知道该怎么做。任何解决方法?