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

思路:

点击刷新时,用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
  })
}
},

  

原文地址:https://www.cnblogs.com/fhysy/p/14765761.html