I can't get my image to show up for some reason. The path of the image should be sent to the component and rendered there. But it just doesn't render. I believe I am using the Vue-CLI if that helps.
This is my folder structure:
src | App.vue | bulbasaur.png | /components | Pokemon.vue App.vue
<template> <div id="app"> <Pokemon location="./bulbasaur.png"/> </div> </template> <script> import Pokemon from './components/Pokemon.vue' export default { name: "app", components: { Pokemon } }; </script> <style> </style> Pokemon.vue
<template> <div> <img :src="`${location}`" /> </div> </template> <script> export default { name: 'Pokemon', props: { location: String } }; </script> <style scoped> </style>
<img data-v-3848655a="" src="./bulbasaur.png">but only a broken image link is displayed.publicfolder instead like this: html-and-static-assets${publicPath}my-image.png">data () {return {publicPath: process.env.BASE_URL}in myexport defaultand then it worked! Thanks!