0

I am trying to pass 2 parameters in a router-link tag.

The component that has the router link:

<template>
<router-link class="pilot-link" :to="{ name: 'PilotCard', params: {cid: pilot.cid , pilotdetails: pilot } }">
  <div class="pilot-card">
    <span>{{ pilot.realname }} with callsign {{ pilot.callsign }} </span>
    <h4>Server: {{ pilot.server }}</h4>
  </div>
  </router-link>
</template>

<script>
export default {
  name: "VatsimPilot",
  props: {
    pilot: {
      type: Object,
      required: true
      }
  }
}
</script>

I want to pass the cid property of the object and also the whole object. I am using the property cid to the route path and i want to use the full object in the destination component.

The route is as follows:

  {
    path: "/pilot/:cid",
    name: "PilotCard",
    props: true,
    component: PilotCard
  },

props is set to true in order for the params to be passed as props to the component.

The destination component:

<template>
            <h1>Pilot Data for {{ pilotdetails }}</h1>
            <h1>Pilot Data for {{ cid }}</h1>
</template>

<script>
export default {
    props: ['pilotdetails','cid']
}
</script>

The above renders nothing for the realname but renders ok for the cid :

enter image description here

If i remove the realname property it seems that it is recognized as Object:

enter image description here

I even tried directly with $route and i get the exact same results as above

<template>
            <h1>Pilot Data for {{ this.$route.params.pilotdetails }}</h1>
            <h1>Pilot Data for {{ this.$route.params.cid }}</h1>
</template>
e4rthdog
  • 5,103
  • 4
  • 40
  • 89
  • Does this answer your question? [vue-router@4.05 object params](https://stackoverflow.com/questions/66864658/vue-router4-05-object-params) – Michal Levý May 16 '21 at 17:33
  • @MichalLevý Its exaclty my problem. But as i understand this is disabled in Vue Router 4.x for a good reason and that we need every property in the url in order to work.... – e4rthdog May 16 '21 at 20:02

0 Answers0