I have an easy question for which I hope you could help:
<div>
<figure :style="{ 'background': 'url(' + item.main_featured + ') center no-repeat' }">
</div>
I want the style attribute 'background' to return color if the URL from API is undefined
Example:
If item.featured_photo is not null:
<figure style="background: url('localhost:6969/image.img') center no-repeat">
If item.featured_photo is null:
<figure style="background: #FFF">
Use a computed property for this:
Edit:
I'm making a bunch of assumptions here with your API and routes. This is a rough stab at generalizing it:
Finally I found it!
Use condition in V-bind:style VueJS:
==>
Hope it helps!
Feed Git's answer is perfect, here's another example with multiple attributes. Just separate with commas:
The form follows (for someone like me who's new at this):