Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda