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

142
Views
src path is not compiled when I use backticks

I'm using VueJs and I'm looping over an object but the path is not interpreted.

This is my code :

<div class="col" v-for="(shortcut, index) in template.header.shortcuts" :key="index">
   <a class="dropdown-icon-item" href="#!">
      <img :src="`@/assets/images/icons/${shortcut.icon}`" alt="add contact"/>
      <span>{{shortcut.label}}</span> 
   </a>
</div>

the problem is in :src the @assets/images/icons/ is not interpreted

about 4 years ago · Santiago Gelvez
3 answers
Answer question

0

Give a try to

:src="require(`@/assets/images/icons/${shortcut.icon`)" 

Pretty much as explained a lot of times here: https://stackoverflow.com/search?q=vue+dynamic+image

about 4 years ago · Santiago Gelvez Report

0

you need to use require method to dynamically upload the local images.

<div class="col" v-for="(shortcut, index) in template.header.shortcuts" :

key="index">
   <a class="dropdown-icon-item" href="#!">
      <img :src="require(`@/assets/images/icons/${shortcut.icon}`)" alt="add contact"/>
      <span>{{shortcut.label}}</span> 
   </a>
</div>
about 4 years ago · Santiago Gelvez Report

0

You can do it like ->

:src='getImage(shortcut.icon)'

and method is

getImage(img) { 
  const path = `${root}/${img}` 
  return path 
}

and another method is

script part

const imgRoot = '@/assets/icons/'

template part

<img :src="`${imgRoot}${shortcut.icon}`" />
about 4 years ago · Santiago Gelvez 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!