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

307
Views
Vue: Get method from component that is in scoped slot

Component Page:

...
<Child>
  <template #form="{ init }">
    <PageForm :init="init"/>
...

Component PageForm:

...
methods: {
  getData() {
    // i need to call in component-grandchild of Page-component
  }
}
...

Component Child (render-function):

...
h('GrandChild', {scopedSlots: {form = props => h('div', this.$scopedSlots.form(props)}}
...

Component GrandChild:

template:

...
<div>
  <slot name="form" :init="init">
<div>
...

script:

...
mounted: {
  // how here get method getData from Page->PageForm without Vuex?
}
...
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I understand that if the structure of the components is constant, then you can try this.$parent.$parent. But this way you can get to the Page, but inside the PageForm is problematic, because this is the slot area.

In theory, i can hang a ref on a component, and get a method through it, but the behavior there is unpredictable...

It is most correct to exchange data through props/emit if the components are adjacent.

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!