I have a website where I’m binding the video or iframe tag to the youtube link I’m getting from API. It only works properly when I’m not binding the link.
This is what i want
I’m using vuejs 2.
This is the code I have. I’m looping over the data I’m getting from API. This code is working fine if I’m using the link directly in src without binding it’s value.
<div
class="gallery-hover-wrap"
data-aos="fade-up"
v-for="(item, index) in gallerydata"
:key="index"
>
<img
v-if="item.image"
:src="item.image"
style="width: 100%"
@click="OpenGalleryPopFun(item)"
class="itemimg"
/>
<div v-if="item.video_link">
<iframe :src="item.video_link" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen>
</iframe>
<!-- <video
no-controls=""
muted="muted"
autoplay="autoplay"
loop="loop"
>
<source src="https://www.youtube.com/watch?v=YklfuduwIGk" type="video/mp4" />
</video> -->
</div>
</div>
2
Answers
Try this:
From the look of your image, it seems that your video url are broken.
Instead of using
https://www.youtube.com/watch?v=YklfuduwIGk
try using an embed linkhttps://www.youtube.com/embed/YklfuduwIGk
This might fix your issue.