video标签播放后,再点击退出当前页,会遮住html结构,并无法关闭问题,怎么解决呀

1.进入视频详情页,并点击播放

 2.点击返回,回退到上衣界面

3.再点击关闭按钮,当前video关闭,在滑到 顶部,发现video还存在,并且层级显示的是最高,盖住了所有的html结构

4.html代码

<template>
  <div class="video-wrapper"
       v-if="detail.videoUrl || startTime">
    <video class="video"
           v-if="detail.videoUrl"
           :src="detail.videoUrl"
           x5-video-player-type="h5-page"
           playsinline
           webkit-playsinline="true"
           controls
           loop
           mtt-playsinline=“true”
           raw-controls></video>
    <div class="poster-img">
      <img :src="detail.coverUrl || detail.imgUrl || ''"
           @error="imgError"
           alt="">
    </div>
    <div class="video-poster">
      <span class="status"
            v-if="startTime && detail.liveStatus != 0"
            :class="'status-' + detail.liveStatus">{{$tc('forum.status', detail.liveStatus - 1)}}</span>
      <div class="play-icon"
           :class="[!startTime && 'video-play-icon']"
           v-if="!timeSize && detail.videoUrl"
           @click="videoPlay">
        <i class="iconfont"
           :class="[detail.liveStatus === 2 ? 'iconyuyuechexiao' : 'iconbofang']"></i>
        <span v-if="detail.liveStatus">{{$tc('forum.status', detail.liveStatus - 1)}}</span>
      </div>
      <div class="count-down"
           v-if="timeSize">
        <span>{{$tc('forum.notice')}}</span>
        <p v-if="parseInt(timeSize[0]) != 0">{{parseInt(timeSize[0])}}{{$tc('home.days', parseInt(timeSize[0]))}} {{timeSize[1]}}:{{timeSize[2]}}:{{timeSize[3]}}</p>
        <p v-else>{{timeSize[1]}}:{{timeSize[2]}}:{{timeSize[3]}}</p>
      </div>
    </div>
  </div>
</template>

5.js代码

<script>
export default {
  name: 'Video',
  data () {
    return {
      timeSize: null,
      startTime: ''

    }
  },
  props: ['detail'],
  mounted () {
    if (this.detail.liveStatus === 2 && !this.detail.videoUrl) {
      this.detail.liveStatus = 3
    }
    this.startTime = this.detail.liveOpenTime || this.detail.liveStartTime
    if (this.detail.liveStatus === 0 && this.startTime && this.startTime > this.detail.systemCurrentTime) {
      this.countDown()
    } else if (this.detail.liveStatus === 0) {
      this.detail.liveStatus = 1
    }
  },
  methods: {
    countDown () {
      if (this.detail.liveStatus === 0) {
        let serverTime = this.detail.systemCurrentTime || new Date().getTime()
        this.timeSize = this.$Common.countDown(this.startTime, serverTime)
        const timeId = setInterval(() => {
          serverTime = serverTime + 1000
          this.timeSize = this.$Common.countDown(this.startTime, serverTime)
          if (!this.timeSize) {
            this.detail.liveStatus = 1
            clearInterval(timeId)
          }
        }, 1000)
      }
    },
    videoPlay () {
      const video = document.querySelector('.video')
      video.style.display = 'block'
      video.play()
      document.querySelector('.poster-img').style.display = 'none'
      document.querySelector('.video-poster').style.display = 'none'
    },
    imgError (e) {
      e.target.src = require('../assets/img/default_img169.jpg')
    }
  },
  beforeDestroy () {
    const video = document.querySelector('.video')
    video.style.display = 'none'
    document.querySelector('.video-wrapper').style.display = 'none'
  }
}
</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值