'Is it possible to globally remove a vue component from the global registry?

I would like to remove a components from Vue at runtime that was previously registered with Vue.component(name, {...}), is this possible ?

We are creating a number of components on the fly in a live development setting and would like to remove old components from memory.

Or is it possible to alter the child components registered with a component at runtime ? Only affecting new component instances built after that of course or refreshed manually.



Solution 1:[1]

Currently in Vue 2.x, when you register a component with Vue.component it's added to the base constructor options object. You can unregister it by simply deleting the component from the components object:

Vue.component('child-component', ChildComponent)

delete Vue.options.components['child-component']

Solution 2:[2]

I believe this should do the trick for you

wm.$destroy() 

Documentation for Destroy

Solution 3:[3]

To display all components:

this.$options.components

To delete a specific component:

delete this.$options.components.NameOfComponent

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 StefanE
Solution 3 Roland