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

165
Views
[Advertencia de Vue]: error en el controlador v-on: "TypeError: no se puede leer la propiedad 'Array' de undefined"

Quiero verificar si las entradas están vacías al hacer clic en el botón. Filtro la matriz si una de las entradas está vacía. Intento agregar un error a la matriz, pero cuando hago clic en el botón aparece el error "'ErrorList' de indefinido" Creo que el error es que trato de obtener una matriz llamada ErrorList dentro de un método llamado save , pero ¿cómo me deshago de este problema entonces? También puedes mirar mi código en codesandbox

 <template> <div> <form> <div v-for="(learning, i) in general.learnings" :key="i"> <input type="text" v-model="general.learnings[i]" maxlength="120" /> </div> <button @click="save">Save</button> </form> </div> </template> <script> export default { methods: { save(e) { e.preventDefault(); this.general.learnings.filter(function (el) { if (el !== "") { return true; } else { this.errorList.push("Error"); } }); }, }, data() { return { errorList: [], general: { learnings: ["", ""], }, }; }, }; </script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

esto sucede porque la referencia de this no hace referencia a su componente dentro del filter .

Simplemente cambie a la función de flecha para solucionar el problema.

 this.general.learnings.filter( (el) => { if (el !== "") { return true; } else { this.errorList.push("Error"); } });
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!