route.params passing down to component props (deprecated since 4.1.4) #1948
-
Regarding #1527 and #1531, and the changelog for 4.1.4, @posva has commented several times on this but I'm left confused because the online docs still suggest this approach for passing in component props with router.push. None of the alternatives suggested in the changelog indicate how we can pass params directly to component props when a route is defined thus:
With component LoginScreen.vue defined: <script lang="ts">
export default defineComponent({
props: {
aProp: String
},
... And I want to route to the component and pass in router.push( { name: 'login', params: { aProp: somevar } } ) Antipattern or not, the vue router docs indicate that the old approach still works, and I can't see another way to pass props in with routes defined with boolean |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
There are not any examples showing that in the docs. If there we’re, we would indeed need to remove them. to put it simply: params are defined in the path, therefore they are part of the URL |
Beta Was this translation helpful? Give feedback.
-
@posva perhaps the docs are just confusing then? https://router.vuejs.org/guide/essentials/passing-props.html#boolean-mode "When props is set to true, the route.params will be set as the component props." |
Beta Was this translation helpful? Give feedback.
-
I'm trying to migrate a big app to v4, until this date the docs still showing the boolean-mode that doesn't work at all and a video using the feature, PLEASE FIX THE DOCS. |
Beta Was this translation helpful? Give feedback.
-
I have the same Problem, but what is the solution? I use params to pass ids as preselections to other views but they should not be part of the path (should not survive page reloads). |
Beta Was this translation helpful? Give feedback.
There are not any examples showing that in the docs. If there we’re, we would indeed need to remove them.
to put it simply: params are defined in the path, therefore they are part of the URL