[Vuejs]-Vue v-for doesn't update directly

0👍

use the vue forceUpdate methodways to rerender component

import Vue from 'vue';
Vue.forceUpdate();

after you update the latest variable, call this one

this.$forceUpdate();

0👍

0👍

There are limitations with how arrays can be re-active in Vue (See: https://v2.vuejs.org/v2/guide/list.html#Caveats).

With this in mind, when you do your update, do it like so:

for (var j = 0; j < tempLatest.length; j++) {
    this.$set(this.latest, j, tempLatest[j]);
}

Note: I’ve not tested this with your code so you might need to play around a little as you’re currently looping the temp list and the indexes might not match but $set is the way to go. You might also try:

this.$set(this, 'latest', tempLatest)

instead of looping each item.

Leave a comment