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

103
Visualizações
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 à 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