Vue+js realizes the fade in and fade out of the video, for your reference, the specific content is as follows A simple video fade-in and fade-out effect is shown in the figure The editor directly posted the code. If you are interested, you can copy and run it. Thank you <template> <div class="video-css"> <div class="videocss" ref="videodom" style="background-color:black;"> <video width="100%" ref="play" style="opacity: 1" :src="videoSrc2"></video> </div> <div class="video-but"> <el-button type="primary" @click="play()">Play</el-button> <el-button type="primary" @click="pause()">Pause</el-button> <el-button type="primary" @click="fadeIn(100)">Fade in</el-button> <el-button type="primary" @click="fadeOut(100)">Fade out</el-button> </div> </div> </template> <script> export default { data() { return { videoSrc: require('../../assets/web_1496003377.mp4'), videoSrc2: require('../../assets/video.mp4') } }, methods: { play() { this.$refs.play.play() }, pause() { this.$refs.play.pause() }, fadeIn(speed) { let that = this var speed = speed || 30 ; var num = 0; var st = setInterval(function(){ num++; that.$refs.play.style.opacity = num/10; if (num>=10) { clearInterval(st); } }, speed); }, fadeOut(speed) { let that = this var speed = speed || 30 ; var num = 10; var st = setInterval(function(){ num--; that.$refs.play.style.opacity = num / 10; if (num<=0){ clearInterval(st); } }, speed); } } } </script> <style lang="less" scoped> .video-css { .videocss { width: 800px; height: 450px; display: flex; justify-content: center; } .video-but { display: flex; margin-top: 20px; justify-content: flex-start; align-content: flex-start; } } </style> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: A brief analysis of the tutorial on installing MySQL 8.0.18 on CentOS 6.8 (RPM method)
>>: How to shut down/restart/start nginx
As one of the most commonly used and important ut...
This article example shares the specific code for...
Achieve results Implementation Code html <div ...
Table of contents 1. Multiple .catch 2. Multiple ...
In react-router, the jump in the component can be...
In many cases, in order to beautify the form, the ...
Table of contents 1. How to monitor Tomcat 2. Jav...
Why use prettier? In large companies, front-end d...
Table of contents Overview 1. Parent component pa...
Table of contents Preface What is data binding? T...
Preface We already know that MySQL uses the SQL S...
What is a memory leak? A memory leak means that a...
1. Overview The information_schema database is th...
There are probably as many modular solutions for ...
Origin: A few days ago, a tester sent a requireme...