[英]Handlebars Template Doesn't Display Data
我的把手模板:
{{#each .}}
{{this}}
{{title}}<br>
{{author}}
{{/each}}
部分數據示例:
[
{
title:"How We Solve Big Problems By Thinking Small",
link:"http://product.hubspot.com/blog/how-our-product-team-thinks-small-to-solve-big-problems",
published:"2015-03-05T13:30:00.000Z",
author:"jboulter@hubspot.com (Jeff Boulter)",
site:"http://product.hubspot.com/blog"
},
{
title:"4 steps to better goals and metrics",
link:"http://engineering.pinterest.com/post/112720487359",
published:"2015-03-04T20:56:27.000Z",
author:"",
site:"http://engineering.pinterest.com/"
},
{
title:"33 Browser Stats You Just Might Believe",
link:"http://code.flickr.net/2015/03/04/browsers-in-2014/",
published:"2015-03-04T17:47:15.000Z",
author:"Phil Dokas",
site:"http://code.flickr.net"
}
]
似乎{{this}}打印出整個blob,就我所能正確顯示它而言。
在github上看項目,完整的上下文, 這個提交 :)
任何幫助非常感謝。
看起來您的有效負載是字符串而不是解析的JSON數組。
嘗試
payload = JSON.parse(payload);
然后在你的車把模板中使用
{{#each payload}}
{{title}}<br>
{{author}}
{{/each}}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.