-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
[DOCS] Clearer usage of prop functions with named views #2493
Comments
This is indeed missing in docs. It should go into https://router.vuejs.org/guide/essentials/passing-props.html if anyone wants to make a contribution |
@posva I would like to pick this up |
go ahead |
Thanks @posva! |
I wished that this PR was merged sooner. Hopefully this ticket was easy to find. |
I also just spent an extraordinary amount of time trying to find a solution until I stumbled upon this ancient issue. Thank you for your efforts, this solved my problem. |
I just spent a large amount of time trying to figure this out.... The docs really did not provide the necessary information here, this should be explicitly exampled in it's own section on named views. Thank you for this. |
Another patterns that is not immediately obvious is: {
path: '/settings',
component: UserSettings,
props: (route) => resolveProps(route),
children: [{
path: 'profile',
props: { // Important bit here
default: (route) => resolveProps(route),
helper: (route) => resolveProps(route)
}.
components: {
default: UserProfile,
helper: UserProfilePreview
}
}]
} If the |
What problem does this feature solve?
I spent a few hours this morning trying to get prop functions with named views to work.
At first I thought that
props
itself was supposed to be a function that returned an object for all named views:After reading and stepping through the
vue-router
code, I eventually figured out the correct implementation is:The docs are not very clear (at least to me) that this is the correct implementation. Not sure if others have had this problem, or if it's just me 🤷♂️
What does the proposed API look like?
My suggestion is to add a section to
Passing Props to Route Components
that explains how to use this withNamed Views
, along with an example.Could also add a link to this section in the
Named Views
section of the docs.The text was updated successfully, but these errors were encountered: