【问题标题】:Array retrieval in HTML5 with the help of LocalStorage借助 LocalStorage 在 HTML5 中检索数组
【发布时间】:2014-10-17 16:59:53
【问题描述】:

我的本​​地存储文件中有 1 个条目 10/10/2014 19:23:34(日期和时间)作为键和

{"entries":[{"name":"s","contact":"s","location":"s","email":"sweety@yahoo.com","detail":"s","f_name":"form1"}]} 

(表单字段记录)作为值

所以我的问题是如何使用 Name = sContact = s 等分隔参数获取此数组...

【问题讨论】:

    标签: arrays html local-storage


    【解决方案1】:

    如果你还没有解析你的数据,你可以像这样解析它:

    var json = localStorage.getItem('10/10/2014 19:23:34');
    
    if (json) {
        var data = JSON.parse(json);
    
        if (data !== null) {
            // then you can try to do something with the data within it
            var entries = data.entries;
    
            for (var i = 0, l = entries.length; i < l; i++) {
                var entry = entries[i];
                console.log(entry.name, entry.contact, entry.location, entry.email);
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      • 2018-09-16
      • 2011-11-02
      • 2012-04-01
      • 1970-01-01
      • 2013-10-08
      • 2013-04-15
      相关资源
      最近更新 更多