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

140
Views
Las imágenes de VueJS de json no se procesarán

Tengo un archivo JSON como este:

 "images": { "thumbnail": "./assets/starry-night/thumbnail.jpg", "hero": { "small": "./assets/starry-night/hero-small.jpg", "large": "./assets/starry-night/hero-large.jpg" }, "gallery": "./assets/starry-night/gallery.jpg" }

Mi código en Vue es:

 <img v-bind:src="data.images.thumbnail" alt="" srcset="" height="100px" width="100px" />

Y "funciona", devuelve un IMG. Pero la ruta de la imagen es ./assets/starry-night/gallery.jpg y creo que por eso no carga.

¿Tengo que engañar al router o algo?

 ./assets/starry-night/gallery.jpg

Salida en Chrome.

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

0

Sus datos se tratan como una cadena, por lo tanto, está buscando la ruta que, por supuesto, no existe. Simplemente defina un const publicUrl = 'http://mysite.test/' en algún lugar para completar la URL de la imagen, como

 <img v-bind:src="publicUrl + data.images.thumbnail" alt="" srcset="" height="100px" width="100px" />

Además, puede hacer referencia a una carpeta haciendo

 <img src="@/assets/starry-night/thumbnail.jpg"/>
about 4 years ago · Juan Pablo Isaza Report

0

Resuelto con:

 created() { this.publicURL = "https://6e222.csb.app"; },

Y movió assets/xxx/ a la carpeta PÚBLICA en lugar de en SRC.

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!