我在尝试使用以下结构的组装站点设置循环遍历我的 JSON 数据时遇到问题:
-src
--content
---index.hbs
--data
---steps-data.json
--partial
---steps.hbs
内容中的 index.hbs 调用部分通过对象,如下所示:
{{> steps steps-data}}
我的 steps-data.json 文件如下所示:
{
"steps":[{
"index": 1,
"title": "Find a product",
"description": "Go to a product page and click on the +PriceTrack short cut to add to your list."
},{
"index": 2,
"title": "Track its price",
"description": "Go to a product page and click on the +PriceTrack short cut to add to your list."
},{
"index": 3,
"title": "Purchase",
"description": "Go to a product page and click on the +PriceTrack short cut to add to your list."
}]
}
在我的 steps.hbs 中,我尝试遍历 JSON 数据,但它没有。
<div class="g-col g-span4">
{{#each steps-data.steps}}
<div class="working-step">
<span class="number"></span><h3>{{title}}</h3>
</div>
<p>{{description}}</p>
{{/each}}
</div>
我遇到的问题是它没有循环通过并且不确定我做错了什么。