我有一个简单的v-for循环,从1到5循环了5次,但是我想从5到1反向循环?这可能吗?我要在列表项中添加一个类,并且要从顶部开始将列表项从最高填充到最低填充
添加|反向不起作用
<section>
<div class='container'>
<h2>Single Line</h2>
<p class="justify_unless_one_line">
This is an example of one line
</p>
<h2>Many Lines</h2>
<p class="justify_unless_one_line">
This is an example of many lines. This is an example of many lines. This is an example of many lines. This is an example of many lines. This is an example of many lines. This is an example of many lines.
</p>
</div>
</section>
答案 0 :(得分:2)
数组过滤器在v2中不再起作用。但是您可以创建自己的i % j == 0
方法。
true
有效,所以:
reversed
"n in [...Array(5).keys()].slice().reverse()"
Vue.config.productionTip = false;
Vue.config.devtools = false;
new Vue({
el: '#app',
methods: {
reverseKeys(n) {
return [...Array(n).keys()].slice().reverse()
}
}
})