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

238
Views
¿Cómo acceder a los campos de datos en Vue desde el método asíncrono?

Código:

 export default { data() { return { nameCity: '', } }, methods: { findCity(event){ event.preventDefault() findCityCust().then(function(response) { console.log(response) this.nameCity = response; }) }, }, }

Y aquí - this.nameCity = respuesta; - arroja un error Uncaught (en promesa) TypeError: No se pueden leer las propiedades de undefined

¿Cómo trabajar con campos de métodos asincrónicos en Vue 3?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

el error es causado por this

diferencias-entre-flecha-y-funciones-regulares: este valor

en function(){} , this es el objeto global

in () => {} , this es la instancia actual de Vue

así que cámbialo a

 findCityCust().then(response => { console.log(response) this.nameCity = response; })

o

 methods: { async findCity(event){ event.preventDefault() this.nameCity = await findCityCust(); }, },
over 4 years ago · Santiago Trujillo Report

0

La función estándar no está vinculada al componente, pruebe la función de flecha:

 export default { data() { return { nameCity: '', } }, methods: { findCity(event){ event.preventDefault() findCityCust().then((response) => { console.log(response) this.nameCity = response; }) }, }, }
over 4 years ago · Santiago Trujillo 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!