Skip to content

docs(guide): add note to props function for named views #2888

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
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/guide/essentials/passing-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,25 @@ The URL `/search?q=vue` would pass `{query: 'vue'}` as props to the `SearchUser`
Try to keep the `props` function stateless, as it's only evaluated on route changes. Use a wrapper component if you need state to define the props, that way vue can react to state changes.

For advanced usage, check out the [example](https://github.com/vuejs/vue-router/blob/dev/examples/route-props/app.js).

::: tip Note when using Named Views
Specify a function for each Named View under the `props` object.

```js
const router = new VueRouter({
routes: [
{
path: '/users',
components: {
default: UsersList,
sidebar: UsersSidebar
},
props: {
default: (route) => ({ user: route.params.id }),
sidebar: (route) => ({ filters: route.query })
}
}
]
})
```
:::