-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Feature: use v-on:click with v-link #390
Comments
Another option might be to give |
FYI, this approach to reducing the onPriority = Vue.directive('on').priority
Vue.directive('link').priority = onPriority - 1
Vue.directive('link-active').priority = onPriority - 2 Note to anyone else doing this, the above code needs to run before your components are compiled. |
An idea is that the object passed to |
I think it is better to use Transition Hooks route: {
canDeactivate(transition) {
transition.abort()
}
} |
That doesn't seem like the correct responsibility. The transition hook is there to determine whether or not you can deactivate the current route. I would not want to shove my event handling code inside that. eg, <a v-link='{name: "home"}'>Cancel</a>
<a v-link='{name: "home"}' v-on:click='saveTheThing'>Save</a> In both cases I'm navigating back to the main page, but canceling and saving are two distinct actions. |
I agree with @rpkilby. A use case is a hamburger menu component with This can be achieved with transition hooks that collapses the menu on each Edit: with a callback in the |
I don't really see the problem here, it makes sense that v-link prevents the default behaviour, you can use a simple method to improve it :) <a @click.prevent="navigateTo('home')">Home</a> Use a method instead: navigateTo: function (nav) {
// Do what you want here.
// this.saveTheThing()
this.$router.go({
path: nav
})
} |
@Gomah with that approach you lose both |
You can still specify an |
the problem isn't the a nice solution would be: <a v-link='{name: "home"}' v-on:click.capture='onClick'>Home</a> just make sure you don't use besides that it would make sense to lower the priority of |
has to be lower than `v-on` - 700
This doesn't appear to work:
I think it's this
e.preventDefault()
. I get why that's there, but can you think of some way we can also handle these clicks from the Component? Maybe a callback could be specified in v-link, like:The text was updated successfully, but these errors were encountered: