前后端不分离的项目中使用jq动态遍历数组渲染页面,显示从第2条数据开始渲染
后台跳转页面携带参数processVos为数组,具体内容为:
var processVos = [ { id: 11, name: "test1", age: 21 }, { id: 12, name: "test2", age: 22 }, { id: 13, name: "test3", age: 23 } ]
html页面中遍历内容:需求为默认显示最新一条数据颜色为砖红色,其他为军校蓝。
<div> <!-- 默认显示最新一条 --> <#list processVos[0] as process> <div class="track1"> <ul> <li> <span>处理人:{{process.name}}</span> <span>年龄:{{process.age}}</span> </li> </ul> </div> </#list> <!-- 从第二条开始遍历 --> <#list processVos as process> <#if process_index !=0> <div class="track2"> <ul> <li> <span>处理人:{{process.name}}</span> <span>年龄:{{process.age}}</span> </li> </ul> </div> </#if> </#list> </div>.track1 { color:brown; } .track2 { color: cadetblue; }
<style>
标签:遍历,name,渲染,process,age,jq,页面 From: https://www.cnblogs.com/webSnow/p/17061602.html
</style>