ケース1でオプションhtml要素がselect内にバインドされないのはなぜですか?
ケース 1: 動作しない
@base{
<select name="" value="" class="custom-select">
@{
println("1"); // this is printed to console
<option value="test">i</option> // this is not shown in html
println("2"); // this is printed to console
}
</select>
}
ケース 2: 仕事
@base{
<select name="" value="" class="custom-select">
@{
println("1"); // this is printed to console
<option value="test">i</option> // this is shown in html
}
</select>
}
アップデート:
すべてのオプション要素を scala テンプレートにバインドするループを作成するにはどうすればよいですか? 次のコードは、オプション要素をバインドしません。実際の戻り型とは何ですか? 空行?
<select name="" value="" class="custom-select">
@{
for(i <- 1 to 10) {
<option value="@i">@i</option>
}
}
</select>