vue+js實(shí)現(xiàn)視頻淡入淡出效果
vue+js實(shí)現(xiàn)視頻的淡入淡出,供大家參考,具體內(nèi)容如下
一個(gè)簡單的視頻淡入淡出效果如圖
小編直接上代碼了有興趣可以拷貝運(yùn)行一下,謝謝
<template> <div class='video-css'> <div ref='videodom' style='background-color:black;'> <video ref='play' :src='http://www.4tl426be.cn/bcjs/videoSrc2'></video> </div> <div class='video-but'> <el-button type='primary' @click='play()'>播放</el-button> <el-button type='primary' @click='pause()'>暫停</el-button> <el-button type='primary' @click='fadeIn(100)'>淡入</el-button> <el-button type='primary' @click='fadeOut(100)'>淡出</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>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. python如何實(shí)現(xiàn)word批量轉(zhuǎn)HTML2. Java8內(nèi)存模型PermGen Metaspace實(shí)例解析3. python excel和yaml文件的讀取封裝4. python3實(shí)現(xiàn)往mysql中插入datetime類型的數(shù)據(jù)5. python爬蟲實(shí)戰(zhàn)之制作屬于自己的一個(gè)IP代理模塊6. moment轉(zhuǎn)化時(shí)間戳出現(xiàn)Invalid Date的問題及解決7. App啟動優(yōu)化-Android性能優(yōu)化8. 詳解docker pull 下來的鏡像都存到了哪里9. Python中內(nèi)建模塊collections如何使用10. Docker鏡像管理常用操作代碼示例
