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

420
Views
TypeError: Javascript Vue V-for indefinido

Tengo una función que devuelve una matriz de objetos como este:

 getMonthDaysGrid() { const totalLastMonthDays = this.getFirstDayOfMonth().dayNumber; const totalDays = this.month.numberOfDays + totalLastMonthDays; const monthList = Array.from({ length: totalDays }); for (let i = totalLastMonthDays; i < totalDays; i++) { monthList[i] = { date: i - totalLastMonthDays + 1, month: this.month.name, year: this.month.year, }; } return monthList; }

cuando intento hacer un v-for div como este:

 <div v-for="(day, idx) in cal.getMonthDaysGrid()" :key="idx"> <p> {{ day.date }} </p> </div>

esto me tira este error:

ingrese la descripción de la imagen aquí

No sé cómo solucionarlo... si hace un bucle en la matriz, ¿cómo es que no puedo acceder a las propiedades del objeto?

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

0

Parece que Vue está tratando de acceder a la propiedad antes de que parezca, por lo que primero tendría que verificar si existe o simplemente darle a la matriz de días un valor predeterminado

intenta cambiar tu código a

 <div v-for="(day, idx) in cal.getMonthDaysGrid()" :key="idx"> <p> {{ day && day.date }} </p> </div>

o para

 <div v-for="(day, idx) in cal.getMonthDaysGrid()" :key="idx"> <p> {{ day?.date }} </p> </div>
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!