2013-03-17 31 views

回答

64

你不得不循環2次:

{{#each userSurvey}} 
    {{#each this}} 
    {{ this }} 
    {{/each}} 
{{/each}} 
+0

有沒有非數字鍵的問題? (我的日期是關鍵,我無法循環訪問數組) – M98 2016-12-06 09:54:34

+0

@Kermani JS中的數組只能有整數作爲鍵。看起來你正在試圖循環一個對象。 – 2016-12-06 19:43:30

1

在這種特殊情況下,如果你想渲染只是「123」,你可以這樣做:

{{#each userSurvey}} 
    {{this.[0]}} 
{{/each}} 

或者更簡單,因爲陣列automatiaclly轉換爲字符串:

{{#each userSurvey}} 
    {{this}} 
{{/each}} 
+1

如果你想渲染2,那麼呢?我知道這是一個相當古老的問題,但是我可以找到針對這個特定問題的唯一良好的文檔。 {{this。[1]}}不起作用.. – 2014-08-28 14:44:23

+0

{{this。[0]}}不起作用! – azuax 2015-03-26 21:14:40

0
{{#each Arr}} 
     {{#each this}} 
      <label>{{this.[0]}}</label> {{this.[1]}}<br> 
     {{/each}} 
    {{/each}} 

這裏是我的數組循環陣列的簡單示例:)