Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

144
Vistas
VueJS images from json won´t render

I´ve got a JSON file like this:

"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"
    }

My code in Vue is:

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

And it "works", it gives back an IMG. But the path of the image is ./assets/starry-night/gallery.jpg and I think that´s why it won´t load.

Do I have to trick the router or anything?

./assets/starry-night/gallery.jpg

Output in Chrome.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Your data is treated as a string, therefore it's looking for the path which of course doesn't exists. Just define a const publicUrl = 'http://mysite.test/' somewhere to complete the image URL such as

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

In addition, you can reference a folder by doing

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

0

Solved with:

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

And moved assets/xxx/ to PUBLIC folder instead of in SRC.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda