Skip to content

Create Component with Slot on runtime #10494

Closed Answered by skoenfaelt
skoenfaelt asked this question in Help/Questions
Discussion options

You must be logged in to vote

Okay it was easier than thought.
https://vuejs.org/guide/components/slots.html#dynamic-slot-names

I knew that documentation but i didnt checked, that the name between the brackets could be fetched from a vFor, since my IDE shows its not connected.

<component
        v-for="(element, index) in componentDefinitions"
        :key="'component_menu_' + element.id + index"
        :class="{ 'mt-2': index > 0 }"
        v-bind="element.builderProps.props"
        :is="element.component"
        @click="openSettingsMenu(element)"
      >
        <template v-for="slotname in element.slots" #[slotname]> slot-placeholder </template>
      </component>

with that, element.slots = string[]

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by skoenfaelt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant