Is there any way to unmount vuejs Instance from DOM? I want to mount and unmount the Vue instance for suited condition.
Is there any way to unmount vuejs Instance from DOM? I want to mount and unmount the Vue instance for suited condition.
There is an vm.unmount() method on Vue 3 instance. If you are using Vue 2 you can use vm.$destroy().
If you are using file template you can use v-if condition on your component. That will remove element from DOM based on condition.
@gurkan-ugurlu third option works well.
My requirement was to mount and unmount the Vue instance. but it turns out, it was to render the DOM element for the suited condition for that template condition works well.
by searching, I understood that template conditions like if-else actually render the component. it's not like applying CSS property display: none;