0

I'm expecting to render with a v-vor image src dynamically with v-bind:src. Even though the image directory seems to be correct (but how could I check it though ?) and other array keys are displayed, I can't see the icon in the template.

structure:   src 
                - assets              // image inside 
                -components           // component inside    
                
<q-card v-for="benefit in benefits" :key="benefit.title">
        <img class="benefits__item-icon" :src="benefit.icon" :alt="benefit.alt">
        <q-card-section >
          <div>{{benefit.content}}</div>
        </q-card-section>
      </q-card>

data() {
      return {
        benefits: [
          {
            icon: '../assets/benefits-icon.svg',  //doesn't diplay
            alt: 'benefits',       //displayes ok
            title: 'plain text',   //displayes ok
            content: 'plain text'   //displayes ok
          },
        ]
       }
     }
john
  • 23
  • 6

1 Answers1

0

Try to change this code

1. <img class="benefits__item-icon" :src="require(benefit.icon)"
    :alt="benefit.alt">