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

141
Vistas
Vue @click.stop still getting the child component

I want to get the child elements of the parent component.

<div
    v-on:click.stop.prevent="onClickTemplateHandler">
    <div>
    <h3 style="">Title</h3>
    <p>{{ lorem }}</p>
    </div>
</div>


...


onClickTemplateHandler(e) {
    console.log(e)
    const innerHTML = e.target.innerHTML
    if (innerHTML) {
      this.value += innerHTML
    }
} 

I've tried to use .self, but I still want the inner of the div be clickable

But, when I click the inside of the div, I am getting the child as the target instead of the parent.

Any suggestion for this one?

Thanks!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I did some workaround

<div>
    <div class="overlay" v-on:click.stop.prevent="onClickTemplateHandler"></div>
    <div>
      <h3 style="padding: 10px;text-align: center;">Header</h3>
    </div>
</div>


...

onClickTemplateHandler(e) {
    const innerHTML = e.target.nextElementSibling.innerHTML
    if (innerHTML) {
      this.value += innerHTML
    }
}

...

.overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0px;
    z-index: 2;
    top: 0px;
    cursor: pointer;
}
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