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()
                }
            }
        },
    },

转载于:https://www.cnblogs.com/cielw/p/16592191.html

Logo

一站式 AI 云服务平台

更多推荐