Template:
<div v-for="feature in features" :key="feature.label">
<img :src="feature.icon">
<div>
{{ feature.label }}
</div>
</div>
Data:
features: {
first: {
icon: '~assets/svg/cards/first.svg',
label: 'First label'
},
second: {
icon: '~assets/svg/cards/second.svg',
label: 'Second label'
},
third: {
icon: '~assets/svg/cards/third.svg',
label: 'Third label'
},
fourth: {
icon: '~assets/svg/cards/fourth.svg',
label: 'Fourth label'
}
}
However I can't seem to find a way for this to work.
:src="feature.icon"returnshttp://localhost:3000/~assets/svg/cards/first.svginstalling
nuxt-svg-loaderadds[Vue warn]: Invalid prop: type check failed for prop "src". Expected String with value "[object Module]", got Moduleif you try to do the one above, in addition to the existing error:src="require(feature.icon)"returns'Cannot find module '~assets/svg/cards/first.svg''x.icon: require('~assets/svg/cards/first.svg')returns'Cannot find module '~assets/svg/cards/first.svg''
All the tutorials that I find online suggest the first method from the list above, but they all use .png/.jpg files
However, just <img src="~assets/svg/cards/first.svg"> without any additional modules works perfectly