VTL语言中的小知识点

在VTL中有三种类型的references:变量(variables)、属性(properties)、方法(methods)。
用$字符开始的references用于得到什么;使用#字符开始的directives(指令)用于作些什么。

第一:#foreach($zz in [1..$info.Rows.Count])

#set($zzz = $zz + 7)

<td id="changeTD$!{item.userId}$zzz" ondblclick="ChangeDropDown(this,'$zz','$item.get_Item($zzz)','$!{item.userid}');">
   <span>$item.get_Item($zzz)</span>           
  </td>

此实例:动态行转列的实例,注意1.id="changeTD$!{item.userId}$zzz避免重复id,2.赋值方式$item.get_Item($zzz)

第二:手动页面加载给每一个input注册验证事件,

View Code
 1  #foreach($item in $dt.Rows)
2 <tr>
3 <td width="170px">
4 <input id="inputID$!{velocityCount}" type="text" class="fenshu" name="inputScore$!{velocityCount}" value="" />
5
6 </td>
7
8 </tr>
9 <script>
10 $(document).ready(function () {
11 $("#inputID$!{velocityCount}").formValidator({ empty: true }).regexValidator({ regExp: "Score", dataType: "enum", onError: "分数:请输入0--100之间的数!" });
12 });
13 </script>
14 #end

注意:$!{velocityCount}从1开始。

第三:view.aspx?userId=$!{item.userId}&fileNumber=$!{item.fileNumber} 传参数时用一个&


 

原文地址:https://www.cnblogs.com/lei2007/p/2202269.html