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

197
Views
VueJS 2.x using string in img src attribute

I have two components a parent, this one,

<template>
  <div class="m-topFooter">
      <div class="container">
        <iconsTop
        v-for = "(element,index) in categories" 
        :key = "index"
        :srcs = "element.img"
        :text = "element.text"
        />
      </div>
  </div>
</template>

<script>

import iconsTop from '../atoms/a-icons.vue'

export default {
    name: "topFooter",
    components: {
        iconsTop,
    },
    data(){
        return {
            categories: [
                {
                    img: "buy-comics-digital-comics.png",
                    text: "digital comics"
                },

that have this data. Categories is an array that contains objects with a string img for the folder path and a text. I wont to pass to his child img and text. This is the son:

<template>
  <div class = "a-icons">
      <!-- TODO: Insert image dinamically -->
      <img :src= "require(`@/assets/img/${srcs}`)" alt = "test">
      <h5>{{text}}</h5>
  </div>
</template>

<script>
export default {
    name: "FooterIcons",
    props: {
      srcs: {
        type: String,
        required: true,
      },
      text: {
        type: String,
      }
    }

I can't to print the src correct. What's the problem?

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!