Vue - Is there an way in v-for to orderBy $index I need to to order an list with v-for by $index. So that the last entry on my array comes first.
I think at the moment there is not a way to sort by the $index using orderBy. However, if you have an attribute in the list that you could use to reverse the order you can use the following.
v-for="item in list | orderBy 'attr' -1"
Check out this documentation http://vuejs.org/api/#orderBy
I attempted with the $index but it doesn't seem to work. https://jsfiddle.net/s7mqscst/
I'd have an ID inside every array item and orderBy it. Or you can have a computed property like so:
computed: {
reverse: function() {
return this.users.reverse();
}
}
and do a v-for="user in reverse" instead of "user in users"
Please sign in or create an account to participate in this conversation.