In this article, we’ll look at how to reverse the order of an array using v-for and orderBy filter in Vue.js.
To reverse the order of an array using v-for and orderBy filter in Vue.js, we use the reverse method.
For instance, we write
<template>
<ul>
<li v-for="item in items.slice().reverse()">
//do something with item ...
</li>
</ul>
</template> to make a copy of the items array with slice.
And we call reverse to return a reversed version of the copied array.
We then use v-for to render the items in the reversed array.
Total Views: 2,281