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

Unclear structure of params object #2503

Closed
rchl opened this issue Nov 27, 2018 · 2 comments
Closed

Unclear structure of params object #2503

rchl opened this issue Nov 27, 2018 · 2 comments

Comments

@rchl
Copy link
Contributor

rchl commented Nov 27, 2018

Version

3.0.2

Reproduction link

https://codesandbox.io/s/lykxn57kr7

Steps to reproduce

Access $route.params[0] for route with a *.

What is expected?

The matched part is returned.

What is actually happening?

Value is undefined. The value is at pathMatch property instead.


https://github.com/vuejs/vue-router/pull/1995/files (@posva) has done a change that changes from having 0 property on the params object to having pathMatch.

I would argue that this is an API breaking change and should be done in a major version release. I would, but params object is not documented very well so it's hard to reason about. (see https://router.vuejs.org/api/#route-object-properties)

As the damage is done already, maybe you can use this bug to improve on documentation and state in documentation for $route.params where the matched part is exposed for routes that are using *.

@posva
Copy link
Member

posva commented Nov 27, 2018

I would argue that this is an API breaking change and should be done in a major version release. I would, but params object is not documented very well so it's hard to reason about. (see https://router.vuejs.org/api/#route-object-properties)

As the damage is done already, maybe you can use this bug to improve on documentation and state in documentation for $route.params where the matched part is exposed for routes that are using *.

Exactly! That was seen as a bugfix because having a param named as 0 was breaking applications in some cases and it wasn't documented. So this won't go into a major version. The docs haven't been updated yet. I plan to do it this weekend once I have time but, as always, I'm open to contributions 😉

@posva
Copy link
Member

posva commented Aug 8, 2020

This was added to docs in the Dynamic Matching section

@posva posva closed this as completed Aug 8, 2020
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

2 participants