In the main App.vue component have an img element with src property hard coded as shown below:
<img
src= './assets/Option01.gif'
alt="Image couln't be loaded"
/>
I'm trying to make this a dynamic parameter where, based on certain conditions the displayed image will change. As shown below, I've refactored the code to bind the src property to a variable:
<img
:src= "image"
alt="Image couln't be loaded"
/>
export default {
name: 'App',
data() {
return {
selectedImage: 0,
images: [
'./assets/Option01.gif',
'./assets/Option02.gif',
'./assets/Option03.gif',
'./assets/Option04.gif',
'./assets/Option05.gif'
]
}
},
computed: {
image(){
return this.images[this.selectedImage]
}
}
}
Unfortunately the console will log the message 'GET http://localhost:8080/assets/Option01.gif 404 (Not Found)'.
Any idea on how to proceed in order to make it work?