Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

206
Visualizações
Local images not loading in Vue

I'm trying to build an image gallery using Vue.js and local images are not loading. I have the src attributes set in the data attribute and can only seem to load images from external sources. Example:

data() {

        return {
            images: [
              "../assets/images/photos/bathroom/bathroom-1.png",
              "https://i.natgeofe.com/n/46b07b5e-1264-42e1-ae4b-8a021226e2d0/domestic-cat_thumb_square.jpg",
            ],
        };
    },

With the rest of my code to scroll through the gallery, the first image doesn't load though the second image does. I figure it's something to with the the way Vue compiles everything, as I can display the image statically with a regular tag and setting the src manually.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Wrap any relative path in require().
In your case:

export default {
  data: () => ({
    images: [
      require("../assets/images/photos/bathroom/bathroom-1.png"),
      "https://i.natgeofe.com/n/46b07b5e-1264-42e1-ae4b-8a021226e2d0/domestic-cat_thumb_square.jpg"
    ]
  })
}
   

Documentation: Vue Loader.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda