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

710
Visualizações
Vuejs - $slots have 'el' is null

WHen I access Vuejs $slots instance I get el = null but type = "div"

template:

  <slot name="head">
    <h1>
      {{ text }}
    </h1>
  </slot>

script

  ...
  const slotCont = this.$slots.head();
  console.log(slotCont[0]);

the .el is null event though we've added sd

parent

<custom-component :key="human.id">
    <template #head>
      <div style="display: flex;">
        this is Head
      </div>
    </template>

    <template #default>
     <h1>Head</h1>
    </template>
</custom-tooltip>

console.log

anchor: null
appContext: null
children: (2) [{…}, {…}]
component: null
dirs: null
dynamicChildren: null
dynamicProps: null
el: null <-- element is null
...
type: "div" <-- div is passed

Error: Cannot read properties of undefined (reading 'el')

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

vm.$slots and vm.$scopedSlots refers to slot inputs passed to the component.

So if you didn't provided any <template #head> in your component, it won't appear inside these properties.

AFAIK, you can't access the default slot from the vm object, Vue renders it as if it was not even in a slot in the first place. You'll need to query that element in a different way.

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