[Vuejs]-Vue โ€“ Force Rerendering Of All Components

2๐Ÿ‘

โœ…

You can use a key attribute in the component root. Change it and the component tree will be rerendered.

Per docs (bold is mine):

It can also be used to force replacement of an element/component
instead of reusing it. This can be useful when you want to:

  • Properly trigger lifecycle hooks of a component
  • Trigger transitions

For example:

<transition>
   <span :key="text">{{ text }}</span>
</transition>

When text changes, the <span> will always be replaced instead of
patched, so a transition will be triggered.

๐Ÿ‘คacdcjunior

Leave a comment