Now I achieve it by next(false),router.replace(path).
But I hope I can add some option to indicate next() to make a replace jump.
Thank you.
Hmm.. could be useful. Maybe a second parameter for next? next(path, useReplace)
/ping @posva @LinusBorg
@hiyuki Why do you need a replace rather than a push? Can you tell us a bit about your use case, please?
I use it as a conditional redirect and doesn't allow user to go back
I use this in beforeEach. When I click the back button at the first time, it won't do anything. I need to click twice. I had to replace next with router.replace after #795 fixed.
This is exactly the same problem I'm having. I'm glad this issue is here because I was hunting around for an option to pass to next() since the option's fields (such as query) are not documented (path is the only one documented).
And yes, $router.go(-1) needs to be called twice (or back button pressed twice) after a redirect. Replace seems to be necessary in this case.
@fnlctrl Aborting the navigation doesn't remove it from history?
No.. there's no browser API to remove anything from history. Therefore,
every navigation is made directly, and aborting a transition will make
vue-router replace the current history with the previous one.
On Sat, Nov 26, 2016 at 11:14 PM Eduardo San Martin Morote <
[email protected]> wrote:
@fnlctrl https://github.com/fnlctrl Aborting the navigation doesn't
remove it from history?—
You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub
https://github.com/vuejs/vue-router/issues/897#issuecomment-263068483,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFTLl3QQzMcfnohUL2xs3BNTEW6AgylKks5rCEzmgaJpZM4KvlvM
.
Most helpful comment
This is exactly the same problem I'm having. I'm glad this issue is here because I was hunting around for an option to pass to
next()since the option's fields (such asquery) are not documented (pathis the only one documented).And yes, $router.go(-1) needs to be called twice (or back button pressed twice) after a redirect. Replace seems to be necessary in this case.