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

274
Vistas
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 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