javascript - Sorting events in Wordpress Bedrock template
Solution:
Thank you for your suggestion.
I also found out that I can get reversed array by just using:
v-for="event in list.slice().reverse()"
This is the related answer: vue.js: reverse the order of v-for loop
Answer
Solution:
Create a computed property and sort the array there.
https://v2.vuejs.org/v2/guide/computed.html
<div id="example">
<p>Original message: "{{ message }}"</p>
<p>Computed reversed message: "{{ reversedMessage }}"</p>
</div>
var component = new Vue({
el: '#example',
data: {
message: 'Hello'
},
computed: {
// a computed getter
reversedMessage: function () {
return this.message.split('').reverse().join('')
}
}
})
You might be able to sort this only once and store in the data object if you wanted to try and be more efficient.
Source