Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

81
Views
Vue: propiedad a la que se accede durante el renderizado pero no definida

Recibo un error cuando cargo mi sitio web. ingrese la descripción de la imagen aquí

Mi código se ve así:

 <div v-if="bookings"> <div class="row"> <div class="col-12 m-2" v-for="booking in bookings" :key="booking.booking_id" > <BookingListItem :booking="booking" /> </div> </div> </div> ...... data() { return { boookings: undefined, }; }, computed: { ...mapState({ user: (state) => state.patient, }), }, methods: { getBookings() { this.id = this.user.id; console.log(this.id); return axios .get('URL/patients/${this.id}/bookings') .then((response) => { this.bookings = response.data; }) .catch((error) => { console.log("Ein Fehler ist aufgetreten: " + error.response); }); }, }, created() { this.getBookings(); }, };

Definí los datos renderizados e incluso agregué un v-if a mi plantilla. ¿Dónde cometo un error? ¡Gracias de antemano!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Después de cambiar el nombre de reservas a reserva y definirlo como el código a continuación, funcionó perfectamente.

 data() { return { bookings: [], }; },
about 4 years ago · Juan Pablo Isaza Report

0

Porque lo define como indefinido en su objeto de datos.

Haga la llamada axios dentro de la función async created() y asígnela a this.bookings, entonces debería desaparecer.

use esperar en lugar de devoluciones de llamada en getBookings y luego haga esto.

 async created(){ this.bookings = await this.getBookings(); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!