Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation doc about using @click with a router-link #1188

Closed
posva opened this issue Feb 22, 2017 · 3 comments
Closed

Add documentation doc about using @click with a router-link #1188

posva opened this issue Feb 22, 2017 · 3 comments

Comments

@posva
Copy link
Member

posva commented Feb 22, 2017

Following #650 . Sometimes we want to use a router-link component to benefit from its visited state or other things but manually handle the @click and it's necessary to use native. Even though it's said on the vue docs, it's better to repeat ourselves a bit

ATM there's no place on the docs where we mention the @click with a router-link so I think we could add a little note at the bottom of : https://router.vuejs.org/en/api/router-link.html

@fnlctrl
Copy link
Member

fnlctrl commented Feb 22, 2017

Hmm after checking the src of router-link, I think maybe it can be made a functional component to support both on and nativeOn (since it doesn't need an instance, and $router reference can be accessed from ctx.parent).
This way we can directly support @click, instead of the counterintuitive @click.native (and we can add support for .native for compatibility)

<router-link @click="foo"/>

@posva
Copy link
Member Author

posva commented Feb 22, 2017

I haven't checked further but it can be useful to transform it into a functional component if possible.
But I don't think it's counterintuitive to use @click.native. Quite the opposite. It's a component so I'll always use @click.native but we can make both ways work

@posva
Copy link
Member Author

posva commented Apr 10, 2018

Closing as we are making the router-link a functional component in #2029

@posva posva closed this as completed Apr 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants