我在使用內置each
幫助程序的轉把中進行迭代。 內的每個塊,我引用電流環路索引{{@index}}
打印的項的連續數:在循環轉把中的物品時向{{@index}}添加偏移
<script id="list-item-template" type="text/x-handlebars-template">
{{#each items}}
<li class="topcoat-list__item">
<a href="#{{@index}}">Item number {{@index}}</a>
</li>
{{/each}}
</script>
這給出以下輸出:
- 項目號0
- 商品編號1
- 商品編號2
- ....
的問題是,我想顯示其與1而不是0
我試圖像{{@index+1}}
對指數進行計算開始的抵消指數,但這只是導致一個
Uncaught Error: Parse error
但你把幫手放在哪裏? –
@Cameron Sima在腳本標記或頁面上的JS文件中,Handlebars加載後 – sricks
謝謝Mobiletainment!你可以給任何參考/解決方案,所以我可以寫它像'aria-label =「{{_ ariaLabel}} {{inc @index'+'1}}」' – KunJ