I wish to dynamically render a v-vor image with v-for image src using v-bind:src. Although the images directory seems to be correct (but how do I check that?) and the other array keys are displayed, I don't see the icons in the template.
structure: src - assets // 图像内部 -components // 组件内部 <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', //不显示 alt: 'benefits', //正常显示 title: 'plain text', //正常显示 content: 'plain text' //正常显示 }, ] } }
P粉3107540942023-09-17 00:37:16
Try to change this code
1. <img class="benefits__item-icon" :src="require(benefit.icon)" :alt="benefit.alt">