Search code examples
javascriptnode.jsvue.jsreloadrerender

Can you force Vue.js to reload/re-render?


Just a quick question.

Can you force Vue.js to reload/recalculate everything? If so, how?


Solution

  • Try this magic spell:

    vm.$forceUpdate();
    //or in file components
    this.$forceUpdate();
    

    No need to create any hanging vars :)

    Update: I found this solution when I only started working with VueJS. However further exploration proved this approach as a crutch. As far as I recall, in a while I got rid of it simply putting all the properties that failed to refresh automatically (mostly nested ones) into computed properties.

    More info here: https://v2.vuejs.org/v2/guide/computed.html