踩了无数个坑,网上很多资源都是没啥用或者互抄的,最后看到一位大佬的博客,才解决的,因此记录一下。附上大佬的博客地址:https://fe.ntnyq.com/plugins/videojs.html#%E4%BA%8B%E4%BB%B6
一、在computed中增加player()
二、在methods中增加方法,并调用this.player.src(填入地址)
<template>
<vue-video-player ref="videoPlayer" />
</template>
<script>
export default {
computed: {
player() {
return this.$refs.videoPlayer.player
},
},
methods: {
toggle() {
const newVideo = 'https://video.com/video.mp4'
this.player.src(newVideo)
},
},
}
</script>
网友评论