I am trying to import an image file from a parent folder in the public/images
folder to a component (Categories.vue
), but the image is not showing up.
This is the folder structure:
And this is the code:
<template>
<div class="container">
<div class="row">
<div v-for="item in items" :key="item.name" class="col-lg-3 col-md-3">
<div class="img-container">
<img v-bind:src="item.src" alt="" class="img-fluid">
<p class="text-dark"> {{ item.subtitle }} </p>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
items: [
{
name:'first',
src:'./public/images/anubis.png',
subtitle: 'Anubis'
},
{
name:'second',
src:'public/images/sarcophagus.png',
subtitle: 'Sarcophagus'
},
{
name:'third',
src:'public/images/ra.png',
subtitle: 'Ra'
},
{
name:'fourth',
src:'public/images/eye-of-ra.png',
subtitle: 'Eyes of Ra'
}
]
}
}
}
</script>
I am pretty sure that I did everything right. I tried using require()
, but also failed. How can I fix this problem?