Skip to content

Commit 9927c6a

Browse files
posvabjornharrtell
andcommitted
docs: add example about passing props
Co-authored-by: Björn Harrtell <[email protected]>
1 parent 79a1e60 commit 9927c6a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

packages/docs/guide/essentials/passing-props.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,20 @@ const routes = [
7878
The URL `/search?q=vue` would pass `{query: 'vue'}` as props to the `SearchUser` component.
7979

8080
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.
81+
82+
## Via RouterView
83+
84+
You can also pass any props directly via `<RouterView>`:
85+
86+
```vue-html
87+
<RouterView v-slot="{ Component }">
88+
<component
89+
:is="Component"
90+
view-prop="value"
91+
/>
92+
</RouterView
93+
```
94+
95+
::: warning
96+
In this case, **all view components** will receive `view-prop`. This is usually not a good idea as it means that all of the view components have declared a `view-prop` prop, which is not necessarily true. If possible, use any of the options above.
97+
:::

0 commit comments

Comments
 (0)