video 视频重新开始播放

vue项目中 需要每次点击出视频的时候重头开始播放

在vue 项目中用的 ref 获取的元素

在 react 中可以使用  document.getElementById('video')   获取元素

autoplay  自动播放
control 有控制条
video.currentTime = 0 把播放时间设置为从零开始
video.play() 播放视频
video.pause() 暂停视频

      <video v-if="isVideo" ref="video" :src="lookImgSrc" autoplay control />

 

    watch: {
        modal: function (val) {
            if (val) {
                this.isVideo = true
                if (this.$refs.video) {
                    this.$refs.video.currentTime = 0
                    this.$refs.video.play()
                }
            }
        },
    },

 

posted @ 2022-08-16 17:03  cielw  阅读(5053)  评论(0)    收藏  举报