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

525
Views
¿Cómo cargar un archivo json local y guardar contenido en un Javascript variable?

Entonces quiero cargar un archivo JSON y guardar su contenido en una variable. Escribí el siguiente código:

<input type="file" id="file" ref="fileSelect" class="custom-file-input" @change="previewFiles" />

 previewFiles() { let files = this.$refs.fileSelect.files var reader = new FileReader(); reader.onload = onReaderLoad; reader.readAsText(files[0]); function onReaderLoad(event){ //console.log(event.target.result); let json = JSON.parse(event.target.result); this.t = json } }

Básicamente, estoy trabajando con vue, así que quiero almacenar el archivo JSON local en la variable t para poder usarlo en otros lugares. Actualmente no se almacena nada en t . Probé varias otras soluciones pero nada funciona. Mi objetivo final es mostrar el contenido de este json como una tabla en otra página y también usar su contenido en otras funciones. Soy nuevo en javascript, por lo que cualquier sugerencia será apreciada.

about 4 years ago · Juan Pablo Isaza
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!