我正在尝试遍历导致以下结果的行:
row 1 - white
row 2 - gray
row 3 - white
row 4 - navy
row 5 - white
row 6 - gray
row 7 - white
row 8 - navy
等等...
我有以下内容,显然只适用于前 5 行,但似乎无法找出正确的方法:
{% if loop.index is odd %}
<div id="{{ target }}" class="band white">
{% elseif loop.index == 2 %}
<div id="{{ target }}" class="band gray">
{% elseif loop.index == 4 %}
<div id="{{ target }}" class="band navy">
{% endif %}
任何帮助表示赞赏。谢谢!