vuejs / router

🚦 The official router for Vue.js
https://router.vuejs.org/
MIT License
3.91k stars 1.19k forks source link

route.params passing down to component props (deprecated since 4.1.4) #1947

Closed qgates closed 1 year ago

qgates commented 1 year ago

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:

{
   name: 'login',
   path: '/login',
   component: LoginScreen,
   props: true
}

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 aProp along the lines of

  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 props: true. Am I missing something here?