需要在 scala.html 中使用计数器变量并使用 @for(i <- list){@(a++)} 显示
Need to use counter variable in scala.html and display using @for(i <- list){@(a++)}
play-framework-twirl-template
您应该在 Scala 集合上使用 zipWithIndex 功能(更多信息请参见 Scala 文档:here);
使用示例:
@for((value, index) <- list.zipWithIndex){
@* Print value *@
@value
@* Print index - first index will be 0 *@
@index
@* Print index + 1 *@
@{index+1}
}
play-framework-twirl-template
您应该在 Scala 集合上使用 zipWithIndex 功能(更多信息请参见 Scala 文档:here);
使用示例:
@for((value, index) <- list.zipWithIndex){
@* Print value *@
@value
@* Print index - first index will be 0 *@
@index
@* Print index + 1 *@
@{index+1}
}