封装视频弹框
<template>
<el-dialog class="videoBox" :title="title" :visible.sync="visible" width="40%" :before-close="handleOnClose" :close-on-click-modal="false" :close-on-press-escape="false">
<video id="video" controls preload autoplay="autoplay" style="width: 100%">
<source :src="videoUrl" type="video/mp4">
</video>
</el-dialog>
</template>
<script>
export default {
name: 'videoData',
data() {
return {
title: null,
visible: false,
videoUrl: null
}
},
methods: {
initVideo(){
this.$nextTick(() => {
let myVideo = document.getElementById('video')
myVideo.pause()
myVideo.load()
});
},
handleOnClose() {
this.videoUrl = null
this.visible = false
},
}
}
</script>
<style>
.videoBox .el-dialog__header {
background-color: #000000;
}
.videoBox .el-dialog__header .el-dialog__title {
color: #fff;
}
.videoBox .el-dialog__body {
padding: 0 !important;
}
</style>
调用视频组件
handleVideo(row){
this.$refs.videoData.title = '视频详情'
this.$refs.videoData.visible = true
this.$refs.videoData.videoUrl = row.wzsp + '?t=' + new Date().valueOf()
this.$refs.videoData.initVideo()
},