我試圖通過使用下劃線的嵌套對象循環。_.each通過嵌套對象循環時產生重複文件
我的對象是這樣的:
var someObject = [{
"name": "Chair",
"title": "Chairs",
"items": [{
"name": "Recliner",
"title": "Recliner Chair",
"type": "Chair",
"quantity": "1"
},
{
"name": "Club/Armchair",
"title": "Club/Armchair",
"type": "Chair",
"quantity": 1
}]
}]
但是當了一回它的對象存儲子對象上,並提出了兩個diplicate
<%_.each(someObject, function(a){%>
<%_.each(a, function(b){%>
<<%_.each(b.items, function(c){%>
<li><%= c.name + " " + c.title></li>
<%});%>
<%});%>
<%});%>
請幫助!
'VAR someList = ...'似乎是一個更好的名字 – Hogan