Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

308
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda