Add onComplete & onAbort to router-link
See original GitHub issueWhat problem does this feature solve?
In 2.2.0 Vue added onComplete
and onAbort
callbacks to router.push
, however there seems to be no equivalvent when using <router-link>
. I’ve seen suggestions that can you use beforeRouteEnter
as an alteranative in some cases, however I have a case where I have a <header>
containing <router-link>
s that remains on the page after a user clicks on the router link, I want to be able to change a property of the header after the user has clicked the link. So beforeRouteEnter
would not work for my case. Ideally I’d like to be able to supply onComplete
and onAbort
to the router-link
directly.
What does the proposed API look like?
Personally I have no preference over how this should look, I’m not experienced enough with vue router to say what is the most idiomatic, however I would expect to be something like the following.
<router-link to="…" on-complete="callback" on-abort="callback"></router-link>
<!-- or -->
<router-link to="…" complete="callback" abort="callback"></router-link>
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:16 (3 by maintainers)
OK, it seems that in v4,
navigate
returns a promise, so one can make a customrouter-link
which awaits onnavigate
and then does additional logic.Implemented by #3114.