Answer the question
In order to leave comments, you need to log in
Why is rendering not happening?
data() {
return {
templatesList: this.$store.getters.templatesList,
};
},
sortByData() {
const arr = this.$store.getters.templatesList;
const n = arr.length;
for (let i = 0; i < n - 1; i++) {
for (let j = 0; j < n - 1 - i; j++) {
if (arr[j + 1].created_at < arr[j].created_at) {
const t = arr[j + 1];
arr[j + 1] = arr[j];
arr[j] = t;
}
}
}
console.log(arr);
this.templatesList = arr;
return true;
},
Answer the question
In order to leave comments, you need to log in
Turn on console warnings. You are trying to modify the array directly in the store, which is not allowed.
const arr = this.$store.getters.templatesList.slice(0);
arr.sort(({created_at:a}, {created_at:b}) => a < b ? -1 : a > b ? 1 : 0);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question