我想自定义圣杯选择标签
我试过这段代码
<g:select name="totalHour" from="${1..20}" value="${holdingVacationInstance}"/>
此代码选择选项如下所示
1, 2, 3, ..., 20
那么,我怎么能这样
0.5, 1.0,1.5, ... , 20.0
你可以这样使用
<g:select name="totalHour" from="${(0.5..20).step(1)}" value="${holdingVacationInstance}"/>
然后它会给出像[0.5, 1.5, 2.5, 3.5, ...]
这样的输出,根据我的担忧,你不能使用非整数步长。http://grails.asia/groovy-range-examples 看这里
使用"from"属性,您必须将选择选项作为列表或Groovy Range提供。
IMO 后者是一种更可靠的方法:
步长为 0.5 的时髦范围