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

133
Views
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 answers
Answer question

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 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!