【发布时间】:2017-07-14 01:24:47
【问题描述】:
有一个issue opened a few years ago on JsRender 允许循环对象而不仅仅是数组。 this:
{
joe:{
name: 'Joe',
status: 'out'},
jane:{
name: 'Jane',
status:'in'},
jill:{
name:'Jill',
status:'away'}
}
最终,该功能实现了,但我发现的示例都没有解决这个特殊问题,它始终是数据的某个子集,as in the examples given at the end of the issue thread,通常在for 的文档中看起来像这样:
[
{
"name": "Pete",
"address": {
"city": "Seattle"
}
},
{
"name": "Heidi",
"address": {
"city": "Sidney"
}
}
]
我如何使用for 或props 来遍历一个字典,就像上面的字典一样? (不是对象数组)无论我尝试什么,我都会收到错误:
…预期的表达式,得到':'
或者任何适合我尝试的排列:
{{for :data}}
{{for :#data}}
{{for :}}
等等。在 JSON 文件中遇到具有这样索引的字典是很正常的(根据我的经验),所以我很惊讶没有找到任何示例。
任何帮助或见解将不胜感激。
我没有使用 JsViews,只使用 JsRender v0.9.87。
【问题讨论】:
标签: jsrender