Skip to content

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

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
18 changes: 18 additions & 0 deletions docs/guide/essentials/passing-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,22 @@ 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.

## Name mode

You can pass props to component using their component name.

``` js
const router = new VueRouter({
routes: [
{
path: '/user-profile',
component: {location: Location, userInfo: UserInfo},

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?

props: { userInfo: route => ({ isNewUser: false }) }
}
]
})
```

The URL `/user-profile` would pass `{ isNewUser: false }` to `userInfo` Component.

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