Skip to content

How could next(path) act like a replace rather than push #897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hiyuki opened this issue Nov 11, 2016 · 7 comments
Closed

How could next(path) act like a replace rather than push #897

hiyuki opened this issue Nov 11, 2016 · 7 comments

Comments

@hiyuki
Copy link

hiyuki commented Nov 11, 2016

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.

@fnlctrl
Copy link
Member

fnlctrl commented Nov 11, 2016

Hmm.. could be useful. Maybe a second parameter for next? next(path, useReplace)
/ping @posva @LinusBorg

@posva
Copy link
Member

posva commented Nov 11, 2016

@hiyuki Why do you need a replace rather than a push? Can you tell us a bit about your use case, please?

@hiyuki
Copy link
Author

hiyuki commented Nov 12, 2016

I use it as a conditional redirect and doesn't allow user to go back

@x531tanxl
Copy link

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.

@jazoom
Copy link

jazoom commented Nov 26, 2016

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.

@posva
Copy link
Member

posva commented Nov 26, 2016

@fnlctrl Aborting the navigation doesn't remove it from history?

@fnlctrl
Copy link
Member

fnlctrl commented Nov 26, 2016 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants