在 data-sly-list 中,我可以循环遍历元素,如以下示例所示
data-sly-list:为提供的对象中的每个可枚举属性重复宿主元素的内容。但是,如果我想循环遍历前 4 个元素或从第 8 个元素到第 10 个元素,该怎么办?
这是一个简单的循环:
<dl data-sly-list="${currentPage.listChildren}">
<dt>index: ${itemList.index}</dt>
<dd>value: ${item.title}</dd>
</dl>
最佳答案
使用这样的东西:
<dl data-sly-list="${currentPage.listChildren}">
<div data-sly-test="${itemList.count > 4 && itemList.count <8}" data-sly-unwrap>
<dt>index: ${itemList.index}</dt>
<dd>value: ${item.title}</dd>
</div>
</dl>
您可以使用计数或索引变量。
关于aem - 如何在AEM中从某个数字循环到某个数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33382893/