Currently, I have stored all the default images for my Vue project in a designated folder. The path to this folder is
. Instead of importing each image individually in my components, I wish to create a file that contains the image paths as constants which can then be imported.web/images/defaults/<imageNames>.png
I attempted the following:
import imageName1 from 'imageName1.png';
import imageName2 from 'imageName2.png';
const DEFAULT_IMAGES = {
imageName1:'imageName1',
imageName2:'imageName2',
};
export default DEFAULT_IMAGES;
After creating this file, I tried to import it in my component like so:
import DEFAULT_IMAGES from '../../assets/images';
And then I attempted to use v-bind
directive on the src
attribute
<img :src="DEFAULT_IMAGES.imageName1" >
However, upon importing, it does not work as expected. Can someone help point out what mistake I might be making?