How should we handle a v-for combined with a v-if in this exemple:
Here my data.json:
[
{
image: 'foo.jpg'
},
{
image: 'foobar.jpg',
video: 'bar.mp4'
},
{
image: 'barfoo.jpg'
}
]
In my vue template, I'd like to render something like this:
<div v-for="(item, key, index) in data" : key="index">
<img :src="item.image">
<video v-if="!!item.video" :src="item.video"></video>
</div >
But as the documentation say, we should avoid v-if with v-for and instead use a computed value. But there I need to render the image even if the json entry doesn't have a video.
That's not a big deal, I've find a solution but I'd like to know the best way to handle this.