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

104
Vistas
Vue Directive get parent Proxy

My goal is to create a directive that when clicked will recursively search through parents until it's finds the first component (vnode) wih the tag role="blinkable" and trigger the function 'blink()'.

I do not know how to find the first parent of the element with the directive 'v-blink-popup'. I've added a role tag to the component incase that would help. But when looking at the el or node of the directive, the parent property is null? There has to be a way to do this.

I've created a directive called v-blink-popup...

BlinkPopup.js (global directive)

const blinkPopup = {
  bind: (el, binding, vnode) => {
    el.style.fontSize = 24 + 'px'
    el.style.backgroundColor = 'red'

    // find parent vnode
    console.log('el', el)
  }
}
export default blinkPopup 
...
Vue.directive('blink-popup', blinkPopup)

BlinkDialog.vue (component)

<template>
  <div role='blinkable'>
      <div class="bg-white rounded">
        <slot />
      </div>
  </div>
</template>

<script>
export default {
  props: {
    value: {
      type: Boolean,
      default: false,
    },
  },
  methods: {
    blink() {
      console.log('blink me')
    },
  },
}
</script>

Page.vue (page file)

<template>
  <div>
    <BlinkDialog>
      Here is my component
      <button v-blink-popup> close </button>
    </BlinkDialog>
  </div>
</template>
about 4 years ago · Juan Pablo Isaza
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