Vue-router: @click on router-link does not work

Created on 10 Sep 2016  ·  7Comments  ·  Source: vuejs/vue-router

Vue.js & vue-router.js version

2.0.0-rc.5 & 2.0.0-rc.4

Reproduction Link

https://jsfiddle.net/oldpig/qos7px6j/1/

Steps to reproduce

click /parent link

What is Expected?

parentClicked handler should be invoked and "parentClicked" message should be logged in console

What is actually happening?

no log

This looks similar to #390

Most helpful comment

@LinusBorg I come from the Django (Python) world, which is well known for having some of the best and most extensive documentation for an OSS project. One of the things the Django documentation does is include relevant notes and disclaimers regarding common mistakes, misunderstandings, or things that are easily overlooked. So overtime, the documentation attains a "collective wisdom."

I've been working with Vue for a little while now, and I think the documentation is great, and has always been improving, but I agree with @plauclair for these types of cases, where a small note in the documentation can save a lot of human time. Just my two cents!

All 7 comments

You need to add the .native modifier.
Next time provide a more concise repro please. It's easier for us to help 😉
https://jsfiddle.net/posva/gh7mzwe7/

@posva thanks for the tip. I really feel this should be in the router-link documentation though. Cheers. 🙂

<router-link> is just a Vue component. to listen for native events on components, you need that modifier - and that is explained in the Vue docs.

It is, but it's still easy to miss and although I do spend a lot of time in the docs, this didn't occur to me at first. Beginners won't think about using modifiers, if they even know about the feature at all.

Adding to docs is a quick thing that will make a lot of us save a lot of time. 👍

@LinusBorg I come from the Django (Python) world, which is well known for having some of the best and most extensive documentation for an OSS project. One of the things the Django documentation does is include relevant notes and disclaimers regarding common mistakes, misunderstandings, or things that are easily overlooked. So overtime, the documentation attains a "collective wisdom."

I've been working with Vue for a little while now, and I think the documentation is great, and has always been improving, but I agree with @plauclair for these types of cases, where a small note in the documentation can save a lot of human time. Just my two cents!

Thanks for The input, I think we really can improve that situation.

you can use watcher to listen router change event

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mitar picture mitar  ·  3Comments

thomas-alrek picture thomas-alrek  ·  3Comments

alexstanbury picture alexstanbury  ·  3Comments

druppy picture druppy  ·  3Comments

Atinux picture Atinux  ·  3Comments