-1

Is there any built-in functionality in Vue that allows for reloading a component, in a way that the page won't be reloaded in the browser, and instead the component would be destroyed and recreated again? That said $router.go() will not work in this case as it reloads the page in browser instead of the current DOM.

Update:

$forceUpdate() also fails as I need everything to be re-initialized again (by letting Vue reinitializing the component instead of doing everything manually).

Arnold Zahrneinder
  • 4,788
  • 10
  • 40
  • 76
  • Possible duplicate of [Can you force Vue.js to reload/re-render?](https://stackoverflow.com/questions/32106155/can-you-force-vue-js-to-reload-re-render) – Jacob Goh Apr 20 '18 at 10:44
  • @JacobGoh: The other post is really useless, had seen it before. and there's no accepted answers in there. – Arnold Zahrneinder Apr 20 '18 at 10:45

1 Answers1

1

Try giving the component a :key="uid" and change this.uid variable when you want to update the component. This just has to be something unique and it should mount again. E.g...

this.uid = Date.now()
Mulhoon
  • 1,852
  • 21
  • 26