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

185
Views
Vue js using asset path for images in components

I am using Vue js 3 to create a webpage.

My (SingleFile) component:

<template>
  <img
    alt="Vue logo"
    src="{{ img_url }}"
    class="-mr-16 object-cover image-focus"
  />
</template>

<script lang="ts">
import { Options, Vue } from "vue-class-component";

@Options({
  props: {
    img_url: String
  },
})
export default class HelloWorld extends Vue {
  msg!: string;
}
</script>

The way I call it:

<CatchImage img_url="@/assets/images/Image.jpg" />


<script lang="ts">
import { Options, Vue } from "vue-class-component";
import Image from "@/components/Image.vue";

@Options({
  components: {
    Image,
  },
})
</script>

This does not load the image. Instead I get an error. Ich I replace the variabvle with the actual path it works fine.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Try

<CatchImage :img_url="require(`@/assets/images/Image.jpg`)" />

Also in template use :src instead of src like this:

:src="img_url"
about 4 years ago · Juan Pablo Isaza Report

0

Did you try to bind image

:src="img_url"
about 4 years ago · Juan Pablo Isaza Report
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!