Freemaker 遍历list,分页取数据

<div class="layui-carousel" id="test1">
    <div carousel-item>
        <#assign n = ((map.appList?size)/2)?ceiling />
        <#list 1..n as num>
            <div>
                <#list map.appList as list>
					<#if (num < 2 && list_index < num*2) || (num > 1 &&  list_index >= (num-1)*2 && list_index < num *2)>
						<div class="list" onclick="jump('${list.url}','${map.token_enc}')">
							<div class="name">${list.name}</div>
							<div class="bg">
								<#if list.code== 'dsharec-resdir'>
									< img src="/static/images/resdir-light.png" class="img-light">
									< img src="/static/images/resdir.png" class="img">
								<#elseif list.code== 'data-analysis'>
									< img src="/static/images/analysis-light.png" class="img-light">
									< img src="/static/images/analysis.png" class="img">
								<#else>
									< img src="/static/images/pmf-light.png" class="img-light">
									< img src="/static/images/pmf.png" class="img">
								</#if>
							</div>
						</div>
					</#if>
                </#list>
            </div>
        </#list>
    </div>
</div>

<#assign> :是定义一个变量来存当前list的数据大小是多少,用于后面的for循环。 

<#list 1..n as num>
</#list>

上面的写法是循环前面计算出来的要循环的次数。

也可以自定义循环几次

<#list 1..100 as i>
</#list>
这个就是循环100次

posted @ 2022-08-04 19:12  码奴生来只知道前进~  阅读(5)  评论(0编辑  收藏  举报