Skip to content
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

addRoute() with name couldn't replace the existing rule with the same name. #3517

Open
klwfwdk opened this issue Apr 9, 2021 · 10 comments · May be fixed by #3519
Open

addRoute() with name couldn't replace the existing rule with the same name. #3517

klwfwdk opened this issue Apr 9, 2021 · 10 comments · May be fixed by #3519
Labels
fixed on 4.x This issue has been already fixed on the v4 but exists in v3 improvement

Comments

@klwfwdk
Copy link

klwfwdk commented Apr 9, 2021

Version

3.5.1

Reproduction link

https://github.com/klwfwdk/addroute-issue

Steps to reproduce

1.click to call router.addRoute() to add a new router named 'About' witch has the same name attribute with a route rule already existing.
2.click router-link 'About'

What is expected?

the route overwrite into new one. The browser should show 'This is an about page New'

What is actually happening?

Still appears as an unupdated component. The browser showed 'This is an about page'

@posva posva added bug fixed on 4.x This issue has been already fixed on the v4 but exists in v3 labels Apr 9, 2021
@posva
Copy link
Member

posva commented Apr 9, 2021

This is a misalignment with v4. We should be able to fix the simple cases without aliases by removing routes from namedMap, pathMap and pathList but It might have some edge cases that aren't fixable without a removeRoute() (v4 only) API. I think it's worth at the very least remove root routes and probably children routes but this requires a bit more investigation to see the side effects.

Note dynamic routing is not supported in vue router 3

@posva posva added improvement and removed bug labels Apr 9, 2021
@klwfwdk
Copy link
Author

klwfwdk commented Apr 9, 2021

This is a misalignment with v4. We should be able to fix the simple cases without aliases by removing routes from namedMap, pathMap and pathList but It might have some edge cases that aren't fixable without a removeRoute() (v4 only) API. I think it's worth at the very least remove root routes and probably children routes but this requires a bit more investigation to see the side effects.

Note dynamic routing is not supported in vue router 3

In this case, I feel the description should be removed from the document, or a warning should be made. The current description is misleading。

In https://router.vuejs.org/api/#router-addroutes

Add a new route to the router. If the route has a name and there is already an existing one with the same one, it overwrites it.

@posva posva linked a pull request Apr 13, 2021 that will close this issue
@dinokopriva
Copy link

Hello. Agree with @klwfwdk . The docs are stating this should be possible in 3.5.0 but it is not.

@mitchierichie
Copy link

mitchierichie commented Jan 25, 2022

Please update the documentation, this is frustrating.

@bourdaisj
Copy link

Sorry to bother here ; is there a known workaround ?

@timhere
Copy link

timhere commented Jan 20, 2023

This has been an issue for over a year and a half, yet it is still detailed in the documentation as a working method for >3.5.0.

I believe the open PR #3519 fixes this issue. If this is not planned to be fixed can we remove it from the docs ASAP? I'm sure there are many like me who are losing days to trying to get this working before unearthing this issue via a search!

@ChristopherJohnson25
Copy link

Is there a known workaround for this issue?

@timhere
Copy link

timhere commented Jul 13, 2023

I believe the only workaround would be to fork vue-router and modify the behaviour as in #3519

@digitalkog
Copy link

digitalkog commented Dec 5, 2023

Reporting we have the same issue and was confused as the docs said this should overwrite an existing route. A couple hours wasted.

@blackdwarf
Copy link

+1 here as well for docs change, though porting over removeRoute to 3.5 would also be welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed on 4.x This issue has been already fixed on the v4 but exists in v3 improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants