Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
Passing slot to grandchild though dynamic component

I have a wrapper component(Wrapper.vue).

<component v-for="c of comps" :key="c.componentName" :is="c.componentName">
      <slot :name="c.componentName">
      </slot>
</component>

const comps = 
      [
        {
          componentName: "Child1",
        },
        {
          componentName: "Child2",
        }
      ];

Child1.vue is something like below

<template>
  <div class="hello">
    <slot name="top">Child1 slot top text</slot>
  </div>
</template>

Child2.vue is something like below

<template>
  <div class="hello">
    <slot name="top">Child2 slot top text</slot>
  </div>
</template>

I want to use the wrapper like below in App.vue

<Wrapper>
      <template slot="slot1">
        <template slot="top">Inner Content1</template>
      </template>
      <template slot="slot2">
        <template slot="top">Inner Content2</template>
      </template>
</Wrapper>

CodeSandbox Link:- https://codesandbox.io/s/mystifying-burnell-ir8un

It is showing default text from Child1 and Child2 not from App.vue What should be done to fix it?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I changed some code and this is the result. The changes I made:

  • you had nested the <template> tag inside App.vue.
  • the wrapper itself needed to have a template for slot named 'top' and inside this template I added a slot with the same name of the component

https://codesandbox.io/s/lucid-smoke-uzgn7?file=/src/App.vue

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!