question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Router-Link doesn't support v-on:click

See original GitHub issue

This doesn’t fire the click event:

<router-link v-on:click="doSomethingCool" to="/">Home</router-link>

Is this intentional? If yes, what is the recommended approach to have Vue click bindings in Router Links?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:17
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

505reactions
LinusBorgcommented, Oct 18, 2016

<router-link v-on:click.native="doSomethingCool" to="/">Home</router-link>

http://vuejs.org/guide/components.html#Using-v-on-with-Custom-Events

59reactions
ricardobanegascommented, Feb 24, 2017

For future reference, if you really need to use it as a Vue-event (not using the .native-approach), then you can do this instead:

<router-link to="/">
     <span v-on:click="doSomethingCool">Home</span>
</router-link>
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use onClick event on react Link component?
I have a callback url in my current component which I am saving in cookie in onClick before transitioning to new route. I...
Read more >
Set an onClick listener on a Link in React | bobbyhadz
To set an `onClick` listener on a Link in React, set the `onClick` prop on the link. The function you pass to the...
Read more >
DataGrid - Unable to call router.navigate in button's onClick
In a module I have inserted an <dx-data-grid> which should become in the last column three buttons which have to navigate to another...
Read more >
React Navigation - Ionic Framework
React Router requires full paths, and relative paths are not supported. ... uses IonItem 's routerLink prop to specify the route to go...
Read more >
<Link> · React Router
The primary way to allow users to navigate around your application. will render a ... path to link to, e.g. /users/123 (relative paths...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found