From within my SectionComponent.vue
file how can I grab an instance of a component I have imported?
import ButtonComponent from './ButtonComponent.vue';
To get an instance of it I want to do something like this:
buttonComponent = Vue.component(ButtonComponent);
I have my component listed/defined in my components array as ButtonComponent
SO in theory I should be able to say:
let buttonComponent = Vue.component('button-component');
but that gives me undefined. What gives?
It does work if I register it globally and then grab an instance.
Is mounted not the right place to test this code? Is my mounted method fired before the imports? I am just looking for a bit of clarity here, if someone could explain I would appreciate it!
ButtonComponent
in your template via a tag:<button-component/>
. You can show the button conditionally using av-if
, or display an array of buttons using av-for
. - tebs1200