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

84
Vistas
Referencing to named slots in vue

I have a vue component with 2 slots (both are filled) and i need to get the position relatively to the page (using getBoundingClientRect method for example), but i can't get access to watchable slot even with refs. Is there any way to do that without this.$el.querySelector method?

<template>
    <div class="watchable-container">
        <slot name="watchable" ref="refWatchable"></slot>
        <div class="bubble-container">
            <div class="bubble">
                <slot name="content">

                </slot>
            </div>
            <div class="bubble-tail"></div>
        </div>
    </div>
</template>

<script>
export default {
    name: "BubblePopover",
    mounted() {
        console.log(this.$slots)
        console.log(this.$refs);
    },
}
</script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The this.$slots member should work.

this.$slots.watchable
// or
this.$slots.watchable.$el

Try using nextTick in your mounted function to give slot time to render.

mounted() {
  nextTick(()=>{
     // your code here
  })
}

You can also add an ID from your slot content add access it by getElementById

Another options is to use the composition API plugin and then access content from the ref.

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