[Vuejs]-How to import a component as prop from another component?

3👍

In your q-dialog component you can use the component tag to dynamically render a passed in component prop. See this stackblitz.

// q-dialog html
<component :is="myComponent" />

In your parent component you’ll want to import the desired component, assign it to a data property and pass it in

// parent component js
import SomeComponent from './SomeComponent.vue'

data () {
    return {
        passedInComponent: SomeComponent
    }

}
// parent component html
<q-dialog :my-component="passedInComponent" />
👤LLai

Leave a comment