Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#3027·vue-router

Add onComplete & onAbort to router-link

Author: XAMPPRockyCreated Nov 10, 2019Updated Jul 15, 2025
Labelsdiscussionfixed on 4.xneeds RFC

What 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.

xml
<router-link to="…" on-complete="callback" on-abort="callback"></router-link>
<!-- or -->
<router-link to="…" complete="callback" abort="callback"></router-link>

Source: vuejs/vue-router

View original on GitHubView discussion on GitHub