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

267
Visualizações
VueJS: Binding image file location data to the src property of img tag is not working

First of all: I am aware of a similar question (Vue JS data binding not working for img src) but I am still posting this question here since the solution of that question did not solve my problem.

I want to display an image in my web application (coded in VueJS), but unfortunately when I bind the image file location string to the src property of the img tag, the image is not shown in the web app.

I have the following code:

<template>
  <div class="home">
    <img src="@/assets/Home.jpg" />
    <img :src="src" />
  </div>
</template>

<script lang="ts">
import Vue from "vue";

export default Vue.extend({
  name: "Home",
  data() {
    return {
      src: "@/assets/Home.jpg",
    };
  },
});
</script>

The first img component gets displayed normally, but the second (which binds data to the src property) not.

I already tried (as suggested in Vue JS data binding not working for img src):

<img :src="require(src)" />

which gave me the error:

[Vue warn]: Error in render: "Error: Cannot find module '@/assets/Home.jpg'"

Thanks for any help!

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