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

Viewed 2224

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.

3 Answers

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']

To display all components:

this.$options.components

To delete a specific component:

delete this.$options.components.NameOfComponent

Related