Closed ProfFan closed 7 years ago
Hi @ProfFan Issue fixed in nprogress #6 . Need code review by @fundon
But you still need to check current path before redirecting to avoid vue-router issue.
beforeEnter: (to, from, next) => {
if (from.path === '/components') {
next()
} else {
next('/components')
}
}
Great, thanks :)
P.S. @luventa Test case:
beforeEnter: (to, from, next) => {
if (from.path === '/components') {
next(false)
} else {
next('/components')
}
}
And the bar does not stop if I navigate to the guarded page when I was in '/components'.
@ProfFan Yes, in that case router stops to call afterEach function. so the progress bar wont stop. If you really need to abort the current navigation, we will need to provide the functionality for stopping progress bar manually.
Maybe we should make a abort()
function?
What about using decorators? Write a decorator function to wrap the push/replace method which is in the VueRouter class, and then inject the nprogress start/end logic around the target.
@xuzhy Yes, that will be an approach. And actually, in previous version, vue-bulma/nprogress exported a function called 'done' to stop itself.
How to replicate:
In
store/menu/index.js
ofvue-admin
.The guard works but progress bar keeps running forever.