ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
如果你想要对一个表格或列表中的每行使用不同的样式,可以使用 loop 对象的 cycle 方法: ~~~ <ul> {% for row in rows %} <li class="{{ loop.cycle('odd', 'even') }}">{{ row }}</li> {% endfor %} </ul> ~~~ cycle 可接受无限数目的字符串。每次遭遇这个标签,列表中的下一项 就会被渲染。