【发布时间】:2019-08-02 12:03:56
【问题描述】:
我有一个针对数据库的查询,它返回多个 JSON 对象作为响应,因此使用 -
创建有效 JSON var intObj = JSON.parse("[" + response + "]");
console.log(JSON.stringify(intObj));
resp.render('abc', {details : intObj});
console.log 输出 / intObj -
[{
"0c057c2b-a4fa-4b8a-89b9-abebf2006704": [{
"tah": {
"id": "92b40e40-58d2-48ff-bfbc-9318b9637ffb",
"ldt": 1564715961014
}
}, {
"th": {
"ldt": 1564715952873
}
}, {
"aah": {
"id": "eb90c2d1-95a1-4f4c-97c3-cbc55a95c57a",
"ldt": 1564715961019
}
}, {
"ah": {
"ldt": 1564715952885
}
}, {
"dec": {
"re": "abc"
}
}]
},
{
"7589668e-62b4-4339-ac06-7591ea1490d3": [{
.....
"dec": {
"re": "test1"
}
}]
}]
我试图在“dec”对象下打印“re”值,但它什么也没显示,怎么办?
{{#each details}}
{{#each ../dec}} // tried {{#each this}} and {{#each dec} and putting another {{#each this}} between details and dec no change in output
<div class="row">{{re}}</div>
{{/each}}
{{/each}}
如果我把代码放在下面,它只是打印对象,所以我认为在传递数据时没有验证问题 -
{{#each details}}
<div class="row">{{this}}</div>
{{/each}}
显示 -
[object Object]
[object Object]
【问题讨论】:
标签: node.js json handlebars.js render