Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

283
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!