🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# `cycle` The `cycle` function cycles on an array of values: <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 3 4 5 6</pre></div></td><td class="code"><div class="highlight"><pre>{% set start_year = date() | date('Y') %} {% set end_year = start_year + 5 %} {% for year in start_year..end_year %} {{ cycle(['odd', 'even'], loop.index0) }} {% endfor %} </pre></div></td></tr></table> The array can contain any number of values: <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 3 4 5</pre></div></td><td class="code"><div class="highlight"><pre>{% set fruits = ['apple', 'orange', 'citrus'] %} {% for i in 0..10 %} {{ cycle(fruits, i) }} {% endfor %} </pre></div></td></tr></table> ### Arguments - `position`: The cycle position