Skip to content

Commit b1343da

Browse files
committed
docs(name-mode): added name mode section in passing props to route component (vuejs#2493)
1 parent cf9dc11 commit b1343da

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/guide/essentials/passing-props.md

+18
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,22 @@ The URL `/search?q=vue` would pass `{query: 'vue'}` as props to the `SearchUser`
7272

7373
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.
7474

75+
## Name mode
76+
77+
You can pass props to component using their component name.
78+
79+
``` js
80+
const router = new VueRouter({
81+
routes: [
82+
{
83+
path: '/user-profile',
84+
component: {location: Location, userInfo: UserInfo},
85+
props: { userInfo: route => ({ isNewUser: false }) }
86+
}
87+
]
88+
})
89+
```
90+
91+
The URL `/user-profile` would pass `{ isNewUser: false }` to `userInfo` Component.
92+
7593
For advanced usage, check out the [example](https://github.com/vuejs/vue-router/blob/dev/examples/route-props/app.js).

0 commit comments

Comments
 (0)