-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Open
Labels
feature requestfixed on 4.xThis issue has been already fixed on the v4 but exists in v3This issue has been already fixed on the v4 but exists in v3
Description
What problem does this feature solve?
This will allow users to hook on:
- redirections to the current route (could be a different hook like
onRedirect
, also triggered byredirect
option) next(false)
calls- navigation delayed and replaced by other navigations:
- eg: users click when async component not finished loading
I'm a bit sceptical about use cases on why to hook on redirects, so I'll love to read if you have usecases
What does the proposed API look like?
router.onCancel((to, from, currentLocation) => {
// from -> original route where the navigation was triggered
// to -> where was it supposed to go
// currentLocation -> location where we ended up (same as this.$route in components and router.currentRouter
})
can be triggered by
router.beforeEach((to, from, next) => {
next(false) // cancel navigation explicitely
})
router.beforeEach((to, from, next) => {
to.fullPath // /foo
from.fullPath // /home
// redirect to /home if we're on /foo
// this will do nothing if we are already on /home
if (to.fullPath === '/foo') next('/home')
else next()
})
JounQin, ancaemcken, alexhung, tkjaergaard, matrunchyk and 20 morebravelincymatrunchyk, voxtobox, MiragePresent, isaaclyman and cypherix93
Metadata
Metadata
Assignees
Labels
feature requestfixed on 4.xThis issue has been already fixed on the v4 but exists in v3This issue has been already fixed on the v4 but exists in v3