vue+js實(shí)現(xiàn)視頻淡入淡出效果
vue+js實(shí)現(xiàn)視頻的淡入淡出,供大家參考,具體內(nèi)容如下
一個(gè)簡單的視頻淡入淡出效果如圖
小編直接上代碼了有興趣可以拷貝運(yùn)行一下,謝謝
<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()">播放</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í)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
vue自定義一個(gè)v-model的實(shí)現(xiàn)代碼
這篇文章主要介紹了vue自定義一個(gè)v-model的實(shí)現(xiàn)代碼,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-06-06詳解如何創(chuàng)建并發(fā)布一個(gè) vue 組件
這篇文章主要介紹了詳解如何創(chuàng)建并發(fā)布一個(gè)vue組件,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-11-11Vue后臺實(shí)現(xiàn)點(diǎn)擊圖片放大功能的示例代碼
這篇文章主要為大家詳細(xì)介紹了如何利用Vue實(shí)現(xiàn)點(diǎn)擊圖片放大功能,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,需要的可以參考一下2022-12-12關(guān)于Vue背景圖打包之后訪問路徑錯(cuò)誤問題的解決
本篇文章主要介紹了關(guān)于Vue背景圖打包之后訪問路徑錯(cuò)誤問題的解決,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-11-11vue.js通過路由實(shí)現(xiàn)經(jīng)典的三欄布局實(shí)例代碼
本文通過實(shí)例代碼給大家介紹了vue.js通過路由實(shí)現(xiàn)經(jīng)典的三欄布局,代碼簡單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2018-07-07vue使用elementui的el-menu的折疊菜單collapse示例詳解
這篇文章主要介紹了vue使用elementui的el-menu的折疊菜單collapse示例詳解,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-12-12