In Mustache, How to get the index of the current Section

前端 未结 13 1120
臣服心动
臣服心动 2020-12-13 03:52

I am using Mustache and using the data

{ \"names\": [ {\"name\":\"John\"}, {\"name\":\"Mary\"} ] }

My mustache template is:



        
13条回答
  •  孤街浪徒
    2020-12-13 04:20

    If you can control the output of the JSON string, then try this out.

    { "names": [ {"name":"John", "index":"1"}, {"name":"Mary", "index":"2"} ] }
    

    So when you make your JSON string, add the index as another property for each object.

提交回复
热议问题