我有存储在本地存储中的数据,我想将其拉入数组。但没有成功......正如您将在下面的代码中看到的那样,我正在尝试 console.log 数组,但它写信给我:
(Chrome 控制台)
Uncaught SyntaxError: Unexpected end of input index.html:204 (anonymous function) index.html:204 e.resolveWith jquery-1.6.min.js:16
e.extend.ready jquery-1.6.min.js:16 c.addEventListener.z jquery-1.6.min.js:16
cordova :: 触发 deviceready 事件!波纹.js:37
8 画布未找到!
这是我的本地存储: 这是代码:
$(function() {
window.localStorage.setItem('Sample block', '{"time":1383107260539,"counter":5}');
track_items_for_chart = [];
for (i = 0; i < window.localStorage.length; i++) {
var key_name = (window.localStorage).key(i);
var time = (window.localStorage.getItem(key_name));
time = (JSON.parse(time)).time;
var counter = jQuery.parseJSON(window.localStorage.getItem(key_name)).counter;
counter = JSON.parse(counter);
track_items_for_chart.push("{ date: " + time + ", km: " + counter + "},");
}
console.log(track_items_for_chart);
});