【发布时间】:2021-05-06 17:23:31
【问题描述】:
我正在尝试使用把手打印我从 json 获取的列表。数据结构很复杂(对我来说),所以我似乎无法找到我需要的嵌套属性。
数据如下:
var data = [{
"response": {
"status": "ok",
"indexes": {
"child": [
{
"isDir": false,
"contentType": "video/avi",
"suffix": "avi",
},
{
"isDir": false,
"contentType": "video/avi",
"suffix": "avi",
}
],
"index": [
{
"name": "A",
"dataIneed": [
{
"id": 291,
"name": "Example1"
},
{
"id": 292,
"name": "Example2"
},
{
"id": 293,
"name": "Example3"
},
]
}
],
"lastModified": 1385842880050
},
"xmlns": "http://example.org/restapi",
"version": "123"
}
}]
在我要打印的表格中:
- 示例1
- 示例2
- 示例3
我的 html / 车把看起来像这样:
<table class="table">
{{#each }}
<tr><td>
{{response.indexes.index.0.dataIneed.0.name}}
</td></tr>
{{/each}}
</table>
并且能够打印:
- 示例1
如何循环得到我想要的结果?
【问题讨论】:
标签: javascript html json handlebars.js