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

134
Vistas
How to make parent data accessible to nested slots' props (Vue 2)?

On a high level let's say I have:

<parent>
    <template v-slot:content="{foo, bar}"> // foo/bar are just data from parent that contains "FOO" / "BAR"
         <child :v-text="foo" :someprop="bar === 'BAR'"> // foo and bar are accessible here
              <template v-slot:content>
                  <grandchild :v-text="foo" :someprop="bar === 'BAR'"> // foo and bar are no longer accessible here
                  </grandchild>
              </template>
         </child>
    </template>
</parent>

In this manner, I can pass any arbitrary data from parent's scope and the direct child can access that. However, if the child also has slots, that child's children will lose context of the grandparent slot (unless I manually expose from child the data that came from parent in its slot template, I guess). And these nested slots can even go deeper to great grand children.

Is there a solution for making parent data available to great grand children's prop values?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can create a named slot inside of the slot template of the parent, within the intermediate component.

This example passes an item property back to the child

Parent Component

<slot name='content' :item='item'>
  Replace Me
</slot>

Middle Component

<parent>
  <template #content='{item}'>
    <slot name='content' :item='item' />
  </template>
</parent>

Child Component

<middle>
  <template #content='{item}'>
    the item is {{item}}
  </template>
</middle>
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