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

147
Views
Vue 3 dynamic image

I am using a v-for to load data on cards. The image is not showing up and not sure why. I though :src = "'item.img'" or :src = "{{item.img}}" would work, but neither are working.

Here is my code

 <div v-for="(item, index) in basicData" :key="index">
      <transition class="slide">
        <div v-if="index >= start && index < end" class="card">
          <div class="card-body">
            <h5 class="card-title">{{item.title}}</h5>
            <img
              :src="'item.img'"
              class="card-img-top"
              :alt="'item.img'"
              style="margin: 20px 5px"
            />
            <p class="card-text">Some quick example text.</p>
          </div>
        </div>
      </transition>

and here is the screen shot

enter image description here

When I hard code src="../assets/featured/pizzaOne.jpeg" the image appears.

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

0

You can create method or computed property:

methods() {
  getImage(imagePath) {
    return require(imagePath);
  }
}

Then in template call that method:

<img
  :src="getImage(item.img)"
  class="card-img-top"
  :alt="item.img"
  style="margin: 20px 5px"
/>
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!