uniapp 刷新video和live-player组件,实现刷新效果

时间:2021-05-24 08:10:34   收藏:0   阅读:0

思路:

点击刷新时,用v-if将video元素隐藏,改变一个值,并在watch里监听这个值,值改变的时候

  

<live-player id="live-video" :src="dataObj.serverAddress" v-if="showVideo" autoplay></live-player>

 

refresh(){
  console.log("刷新视频")
  this.refreshdata+=1;
  this.showVideo = false;
}

  将showVideo变为true的方法放在this.$nextTick()中,触发浏览器的重排,可以使浏览器重新获取video和live-player的src值,重新加载视频资源。

watch:{
refreshdata (old,new) {
  this.$nextTick(() => {
    this.showVideo = true
  })
}
},

  

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!