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

266
Views
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
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!