相关疑难解决方法(0)

在Mustache中,如何获取当前Section的索引

我正在使用Mustache并使用数据

{ "names": [ {"name":"John"}, {"name":"Mary"} ] }
Run Code Online (Sandbox Code Playgroud)

我的小胡子模板是:

{{#names}}
    {{name}}
{{/names}}
Run Code Online (Sandbox Code Playgroud)

我想要做的是获得数组中当前数字的索引.就像是:

{{#names}}
    {{name}} is {{index}}
{{/names}}
Run Code Online (Sandbox Code Playgroud)

打印出来

John is 1
Mary is 2
Run Code Online (Sandbox Code Playgroud)

是否可以使用Mustache获得此功能?或使用把手或其他扩展?

templates mustache

55
推荐指数
5
解决办法
5万
查看次数

标签 统计

mustache ×1

templates ×1