Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
Vue: Handover id to other component

Community

In my application I render a a list of doctors. This list is displayed in my DoctorView component like this:

 <div    
  class="col-12 m-2"
  v-for="recommendation in recommendations"
  :key="recommendation"
  >
   <DoctorListItem :recommendation="recommendation" />
 </div>

What I am trying to do is, that when a user clicks on an entry in this list, I want the application to open a detail page about this doctor. So in my DoctorListItem component I use a router-link:

<router-link
      :to="`/doctors/${recommendation.doctor.doctor_id}`"
      class="stretched-link"
    ></router-link>

Now I need to give this id to the ReadDoctorView, which displays the detailed informations about the selected doctor. Because I need this information to load the details of the selected doctor. This id is in my DoctorView and in my DoctorListItem available, but I can't get it to my ReadDoctorView component. I tried this with props but i am an absolute beginner and I am not sure where to define the props and how to handle the data.

In my ReadDoctorView I need a method like the one below to get the selected doctor:

methods: {
     getDoctorById() {
       this.id = this.recommendation.doctor.doctor_id;
       console.log(this.id);
       return axios
         .get('http://URL/doctors/${this.id}')
         .then((response) => {
           this.doctordetails = response.data;
           console.log(id);
         })
         .catch((error) => {
          console.log("Ein Fehler ist aufgetreten: " + error.response);
         });
     },
  },

I hope my explanation makes sense and you can understand what I am trying to accomplish. Thank you in advance for any tips!

PS: I receive these warnings because vue router doesn't know these routes. Any idea how to stop these warnings: enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In Vue router params from the route can be accessed by accessing $router object try accessing by using solution I hope it will work:

this.id = this.$route.params.id
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda