[Vuejs]-Dynamically loading components in Vue

1👍

I am thinking that you can use a v-if that loads different components depending on the data passed.

<TitleSceneComponent v-if="booleanValueOrCondition" />
<ChoiceSceneComponent v-if="anotherBooleanValueOrCondition" />

This way components can be loaded depending on your conditions.

👤Teej

0👍

I would use vue router to something like this: https://router.vuejs.org/guide/#html

0👍

You can do this:

<component
  :is="sceneComp"
  v-bind="options"
>
</component>

=============================

computed: {
  sceneComp() {
    return () => import(`./scenes/common/${this.scene}Component.vue`);
}
👤Odd

Leave a comment