如何在 play2 中声明和递增变量? (在 .scala.html 模板中)
伪代码:
@counter
@for(l <- list){
<span class="data-@counter">
</span>
@(counter += 1)
}
最佳答案
你真的需要计数器和递增吗?你可以这样做:
@for((l, index) <- list.zipWithIndex){
<span class="data-@index">@l</span>
}
方法 zipWithIndex
创建元组列表。
关于java - Play2 - 模板 -> 递增,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12251504/