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

286
Visualizações
Trigger focus and blur on router-link on mouse interaction (Vue)

I have a component with a router-link as the "root element" in Vue and I would like to trigger focus on mouseenter and blur on mouseleave. I have currently set it up like this:

<template>
  <router-link
    :to="LINK"
    ref="card"
    @mouseenter="focus"
    @mouseleave="blur"
  >
    CONTENT
  </router-link>
</template>

<script>
export default {
  methods: {
    focus() {
      this.$refs.card.$el.focus();
    },
    blur() {
      this.$refs.card.$el.blur();
    },
  }
}
</script>

But focus and blur doesn't get triggered when I hover or leave the mouse on the link with this code. I get no errors in the console either. Is there anything additional that needs to be done in order for it to work?

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

0

Really dumb issue, but I simply had to add @mouseenter.native and @mouseleave.native in order to trigger the methods as router-link is obviously a component.

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