最近在用freemark写前端页面,在进行循环遍历的时候发现一件挺有意思的事情。
下面代码是正确功能实现:
function manage_publicRecourse_customer_label(row) {
$("#publicResource_lable").html('');
var html1 = "<span style=\"background-color:#1abb9c;color:white;font-size:18px\">";
var html2 = "</span> ";
var b = row.customerLable.split(',');
for(var i=0;i<b.length;i++){
$("#publicResource_lable").append(html1+b[i]+html2);
}
}
之前在freemark中并没有尝试过,一直认为遍历必须用freemark的标签。然后就写出了如下的代码:
function manage_publicRecourse_customer_label(row) {
$("#publicResource_lable").html('');
var html1 = "<span style=\"background-color:#1abb9c;color:white;font-size:18px\">";
var html2 = "</span> ";
<#list row.customerLable?split(",") as customerLable>
$("#publicResource_lable").append(html1+${customerLable}+html2);
</#list>
}
这里运行后 在页面上debugger的时候编译后 一直为空,值也显示不出来,由此引发以下想法:
freemaker的加载是在页面进行显示前就已经加载完成,在编译后的页面上,看不到任何freemaker的标签。