【发布时间】:2021-10-01 06:32:17
【问题描述】:
在我的项目中,我有 4 组视频同时渲染,但一次只显示一个。用户可以通过点击箭头键转换到下一个/上一个视频。每当用户按下一个键转到下一个/上一个视频时,我希望在这些视频上进行淡入/淡出过渡。
我尝试过使用 vue 过渡,但他们不知道如何将它们与 v-show 而不是 v-if 一起使用,棘手的部分是所有视频只渲染一次并且永远不会被删除,它们只会被隐藏。下面是这些视频的 HTML 代码。
<div class="video-container" v-show="currentVideo === 1">
<video @ended="countLoop" ref="video1" muted autoplay>
<source src="../assets/videos/video1.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
</div>
<div class="video-container" v-show="currentVideo === 2">
<video @ended="countLoop" ref="video2" muted>
<source src="../assets/videos/video2.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
</div>
<div class="video-container" v-show="currentVideo === 3">
<video @ended="countLoop" ref="video3" muted>
<source src="../assets/videos/video3.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
</div>
<div class="video-container" v-show="currentVideo === 4">
<video @ended="countLoop" ref="video4" muted>
<source src="../assets/videos/video4.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
</div>
【问题讨论】:
标签: javascript css vue.js animation css-transitions