-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Adding name mode section in passing props to route component #2499
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
Conversation
@posva Is there any issue with this PR. Why its is not getting merged? Please let me if there are changes to be done. |
No, no problems. It's not getting merged yet because I haven't checked :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behavior is not really one of the "modes" and the example in the documentation has a comment/example that explains it already:
// for routes with named views, you have to define the `props` option for each named view:
{
path: '/user/:id',
components: { default: User, sidebar: Sidebar },
props: { default: true, sidebar: false }
}
Perhaps we could remove this comment/example from the code at the top of the page and move it to a new section at the bottom titled "Usage with named views". This way it would be explained as an explicit feature which would be harder to miss. You could even mention that the rules still apply for using the different modes. Maybe something like this:
## Usage with named views
A route with [named views](named-views.html) must have an explicitly defined `props` option for each named view.
In the following example, the `header` and `default` views will recieve the `id` prop, but the `footer` view will not.
```js
const router = new VueRouter({
routes: [
{
path: '/user/:id',
components: {
header: Header,
default: User,
footer: Footer
},
props: {
header: true,
default: true,
}
}
]
});
```
The `props` option for each named view can still be defined using any of the available modes:
```js
const router = new VueRouter({
routes: [
{
path: '/user/:id',
components: {
header: Header,
default: User,
footer: Footer
},
props: {
header: { sticky: true },
default: route => route.query,
footer: true,
}
}
]
})
```
routes: [ | ||
{ | ||
path: '/user-profile', | ||
component: {location: Location, userInfo: UserInfo}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be components
instead of component
?
I think having this documented at https://router.vuejs.org/guide/essentials/passing-props.html as it currently is makes more sense |
Fixes (#2493)