The element or ID supplied is not valid. (videojs) elementui
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
项目问题记录 elementui ,videojs
项目用到elementui ,videojs,为了hls格式的视频流在弹框关闭后停止刷新,使用了dispose()注销player
再次打开弹窗报错
The element or ID supplied is not valid. (videojs)
后发现因el-dialog懒加载,videojs找不到需要初始化的playerID,因为需要防止hls视频流一直刷新必须要删除dom
完整解决方案如下(无关代码有省略):
dialog捕捉关闭事件,开启事件,开启后事件
<el-dialog title="视频播放" :visible.sync="videoVisible" customClass="customClass" @close="closevideo" @open="open" @opened="openvideo">
<div style="position:relative;" v-html="videohtml">
</div>
</div>
相关methods:
closevideo() {
if (this.player) {
this.player.dispose(); // 该方法会重置videojs的内部状态并移除dom
this.videohtml = '';
}
this.videoVisible = false;
},
handlePlay() {
this.videoVisible = true;
},
open(){
this.videohtml = '<video id="currentPlayer" class="video-js vjs-big-play-centered vjs-default-skin " style="width:700px;height:393.75px" muted></video>';
},
openvideo() {
setTimeout(() => {
this.$nextTick(() => {
this.player = Videojs("currentPlayer", this.options);
});
},300)
}
over
GitHub 加速计划 / eleme / element
54.06 K
14.63 K
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:3 个月前 )
c345bb45
7 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 7 个月前
更多推荐
已为社区贡献1条内容
所有评论(0)