我对 Jade 中的每个循环有一些问题。我必须在行中显示 2 个项目,但这对我不起作用。
each item,i in feature.items
.col-mb-8.col-tb-12.col-dt-6
h4.b--feature__title!=item.title
p.b--feature__text!=item.text
我需要在奇怪的项目之前添加 .col-group 。 Jade 可以吗?有人能帮助我吗?
最佳答案
您可以执行类似的操作,为偶数和奇数元素提供不同的输出:
each item,i in feature.items
- if (i % 2) {
.col-mb-8.col-tb-12.col-dt-6
h4.b--feature__title!=item.title
p.b--feature__text!=item.text
- } else {
.col-mb-8.col-tb-12.col-dt-6
h4.b--feature__title!=item.title
p.b--feature__text!=item.text
- }
只需对标签或类进行所需的更改即可。
关于javascript - 使用 Jade 在每个循环中显示一行中的两个项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40789558/