Reputation: 739
I'm working on a requirement where I planned to dynamically set the URL on load of the component. I have a tag where the src attribute will be set from a service call which would return image. If the image is not present I need to set a fallback image. How can I handle this.
The image is in binary code format(.png) image
Upvotes: 1
Views: 202
Reputation: 1356
I had a similar problem. This is my solution :
1)For the image you set a dynamic src like this :
< img :src="image" >
Data() { return { image : "path", } }
< link rel="preload" type="image" or type="img/png" href="path" >
this. image = messageImg
I hope this is helpfull.
Upvotes: 2