How do I reverse the order of an array using v-for and orderBy filter in Vue JS?

后端 未结 6 1607
生来不讨喜
生来不讨喜 2021-02-02 05:58

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

6条回答
  •  伪装坚强ぢ
    2021-02-02 06:37

    The v-for directive doesn't support iterating backwards, so if you want to order by newest you're going to need to add another field to indicate when the item was added, or change id to increment every time an item is added.

    Then, with field being the field indicting the order added:

提交回复
热议问题