给 velocity 循环的label中加一个序号

序号从0开:

[#foreach($!{item} in $!{list})
    #if($foreach.count==$!{list.size()})
        {"index": $foreach.index, "label": "$!{item.tips}", "value": "$!{item.fun}"}
    #else
        {"index": $foreach.index, "label": "$!{item.tips}", "value": "$!{item.fun}"},
    #end
#end]

序号从1开:

[#foreach($!{item} in $!{list})
    #if($foreach.count==$!{list.size()})
        {"index": $foreach.count, "label": "$!{item.tips}", "value": "$!{item.fun}"}
    #else
        {"index": $foreach.count, "label": "$!{item.tips}", "value": "$!{item.fun}"},
    #end
#end]

posted @ 2023-07-29 11:38  锐洋智能  阅读(132)  评论(0编辑  收藏  举报