[Vuejs]-Insert slot into a component instance

0👍

is it compulsory that you use <slot>?
Vue comes with a directive called <component> for loading components dinamically, you can pass your component using the is special attribute.

<template>
<div>
    <component :is="dynamicComponent">
</div>
</template>

The script:

export default {
  computed: {
    dynamicComponent(){
      return Comp2 //the class, not the instance
    }
  }
}

Leave a comment