Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 循环浏览把手中的json数据_Javascript_Json_Handlebars.js - Fatal编程技术网

Javascript 循环浏览把手中的json数据

Javascript 循环浏览把手中的json数据,javascript,json,handlebars.js,Javascript,Json,Handlebars.js,在Handlebar网站上,我可以看到如何在数组中循环,但我试图通过数组对象进行查看,但没有运气 这是我的数据,我使用jquery和jsonp命令返回 [ { "id": 95, "user_id": 6, "status": 1, "name": "Lost & Co", "country": { "code": "GB", "name": "Unit

在Handlebar网站上,我可以看到如何在数组中循环,但我试图通过数组对象进行查看,但没有运气

这是我的数据,我使用jquery和jsonp命令返回

[
    {
        "id": 95,
        "user_id": 6,
        "status": 1,
        "name": "Lost & Co",
        "country": {
            "code": "GB",
            "name": "United Kingdom"
        },
        "city": "London",
        "venue": "Lost & Co",
        "fsqid": "512fb191e4b0f660fda426eb",
        "address": "160 Putney High Street",
        "postcode": null,
        "lat": "51.461322924772",
        "lng": "-0.21689196269354",
        "phone": "+442087802235",
        "description": null,
        "date": "2014-05-10",
        "time": "",
        "image": null,
        "image_thumb": null,
        "website": "",
        "twitter": null,
        "tickets": "",
        "fb_event": null,
        "created_at": "2014-04-24 12:20:09",
        "updated_at": "2014-04-24 12:20:09"
    },
    {
        "id": 96,
        "user_id": 6,
        "status": 1,
        "name": "Lost & Co",
        "country": {
            "code": "GB",
            "name": "United Kingdom"
        },
        "city": "London",
        "venue": "Lost & Co",
        "fsqid": "512fb191e4b0f660fda426eb",
        "address": "160 Putney High Street",
        "postcode": null,
        "lat": "51.461322924772",
        "lng": "-0.21689196269354",
        "phone": "+442087802235",
        "description": null,
        "date": "2014-05-24",
        "time": "",
        "image": null,
        "image_thumb": null,
        "website": "",
        "twitter": null,
        "tickets": "",
        "fb_event": null,
        "created_at": "2014-04-24 12:20:57",
        "updated_at": "2014-04-24 12:20:57"
    },
    {
        "id": 94,
        "user_id": 6,
        "status": 1,
        "name": "Lost Society",
        "country": {
            "code": "GB",
            "name": "United Kingdom"
        },
        "city": "London",
        "venue": "Lost Society",
        "fsqid": "4bbcf543593fef3b35de0256",
        "address": "697 Wandsworth Rd",
        "postcode": "SW8 3JF",
        "lat": "51.467991033249",
        "lng": "-0.14425992965698",
        "phone": "+442076526526",
        "description": null,
        "date": "2014-05-31",
        "time": "",
        "image": null,
        "image_thumb": null,
        "website": "http://www.lostsociety.co.uk/index2.html",
        "twitter": "lostsocietybar",
        "tickets": "",
        "fb_event": null,
        "created_at": "2014-04-24 12:18:53",
        "updated_at": "2014-04-24 12:18:53"
    },
    {
        "id": 97,
        "user_id": 6,
        "status": 1,
        "name": "Campus North",
        "country": {
            "code": "GB",
            "name": "United Kingdom"
        },
        "city": "Newcastle",
        "venue": "Campus North",
        "fsqid": "533b05b0498ea89103652747",
        "address": "5 Carliol Square",
        "postcode": null,
        "lat": "54.973037719727",
        "lng": "-1.6087431907654",
        "phone": null,
        "description": null,
        "date": "2014-06-12",
        "time": "",
        "image": null,
        "image_thumb": null,
        "website": "",
        "twitter": null,
        "tickets": "",
        "fb_event": null,
        "created_at": "2014-04-24 17:56:26",
        "updated_at": "2014-04-24 17:55:55"
    },
    {
        "id": 91,
        "user_id": 6,
        "status": 1,
        "name": "Glastonbury",
        "country": {
            "code": "GB",
            "name": "United Kingdom"
        },
        "city": "Pilton",
        "venue": "Glastonbury",
        "fsqid": null,
        "address": null,
        "postcode": null,
        "lat": null,
        "lng": null,
        "phone": null,
        "description": null,
        "date": "2014-06-28",
        "time": "",
        "image": null,
        "image_thumb": null,
        "website": "http://www.glastonburyfestivals.co.uk/",
        "twitter": null,
        "tickets": "",
        "fb_event": null,
        "created_at": "2014-04-22 12:08:32",
        "updated_at": "2014-04-22 13:06:51"
    },
    {
        "id": 92,
        "user_id": 6,
        "status": 1,
        "name": "Glastonbury",
        "country": {
            "code": "GB",
            "name": "United Kingdom"
        },
        "city": "Pilton",
        "venue": "Glastonbury",
        "fsqid": null,
        "address": null,
        "postcode": null,
        "lat": null,
        "lng": null,
        "phone": null,
        "description": null,
        "date": "2014-06-29",
        "time": "",
        "image": null,
        "image_thumb": null,
        "website": "http://www.glastonburyfestivals.co.uk/",
        "twitter": null,
        "tickets": "",
        "fb_event": null,
        "created_at": "2014-04-22 12:08:46",
        "updated_at": "2014-04-22 13:07:27"
    },
    {
        "id": 80,
        "user_id": 6,
        "status": 1,
        "name": "TBA",
        "country": {
            "code": "ES",
            "name": "Spain"
        },
        "city": "Ibiza",
        "venue": "TBA",
        "fsqid": "51fab9b1498e0ced82ae61d0",
        "address": "Mediterranean Sea",
        "postcode": null,
        "lat": "38.970107",
        "lng": "1.305714",
        "phone": null,
        "description": null,
        "date": "2014-09-12",
        "time": "",
        "image": null,
        "image_thumb": null,
        "website": "",
        "twitter": null,
        "tickets": "",
        "fb_event": null,
        "created_at": "2014-02-27 00:41:49",
        "updated_at": "2014-02-27 00:41:49"
    }
]
我试过了,但没用。我错过了什么明显的东西吗

    <ul>
        {{#each}}
        <li>
            <h3>{{ venue }}</h3>
        </li>
        {{/each}}
    </ul>
    {{{#各}
  • {{地点}
  • {{/每个}}

您需要为以下各项提供上下文:

{{{#each.}
  • {{地点}
  • {{/每个}}
    您所缺少的是,您需要让Handlebar知道它是您想要迭代的根对象

    {{#each .}}
        <li>
            <h3>{{ venue }}</h3>
        </li>
    {{/each}}