I am using Vue JS to do viewmodel bindings. In my data
object I have an array of items that are sorted in ascending order (oldest to newest) and I\'d like to keep i
For my use case (which is admittedly, apparently different than the OP...) I wanted to have the indices of the Array in reverse order in the v-for "loop."
My solution was to create a Vue app method reverseRange(length)
that returns an Array of integers from length-1 to 0. I then used that in my v-for
directive and simply referred to my Array elements as myArray[index]
every time I needed it.
That way, the indices were in reverse order and I was able to then use them to access elements of the Array.
I hope this helps someone who landed on this page with this subtle nuance in their requirements like me.