当前位置: 首页 > article >正文

弹框调取阿里云播放器一直报错 TypeError: 没有为播放器指定容器

弹框调取阿里云播放器一直报错 TypeError: 没有为播放器指定容器

<template>
  <el-dialog
    v-model="dialogpeopleVisible"
    :before-close="handleClose"
    class="aliyunplayDialog"
  >
    <!-- :show-close = "false" -->
     <div>查看</div>
    <div  class="prism-player" id="playerContainer" ></div>
  </el-dialog>
</template>

<script setup>
import { ref, reactive, onMounted } from "vue";
const player1 = ref(null);
const isAliplayerLoaded = ref(false)
const init = () => {
  if (player1.value) {
    // 如果已经创建了,就销毁
    player1.value.dispose();
    player1.value = null;
  }


  player1.value = new Aliplayer({
    id: 'playerContainer',
    source: infoValue.value,
    width: "100%",
    height: "522px",
    ratio: 16 / 9,
    autoplay: true,
    isLive: false,
  }, function (player) {
    console.log("The player is created");
  });
};
const dialogpeopleVisible = ref(false);

const infoValue = ref({});
const openDialog = (bool, info) => {
  console.log(info, "009990999jjggff");
  dialogpeopleVisible.value = bool;
  infoValue.value = info;
  init()
};
const handleClose = () => {
  dialogpeopleVisible.value = false;
  player1.value.dispose();
};

defineExpose({ openDialog, handleClose });
</script>
<style lang="scss">
.prism-player{
width:750px;

}
</style>

openDialog 打开弹框init初始化阿里云播放器组件,但是一直报错
dialog打开后opened事件(因为aliplayer的创建时机是需要控制创建时机的,不然会找不到容器)

在这里插入图片描述
调取阿里云播放器组件的方法写在 @opened=“opena”

<template>
  <el-dialog
    v-model="dialogpeopleVisible"
    :before-close="handleClose"
    class="aliyunplayDialog"
    @opened="opena" 
  >
    <!-- :show-close = "false" -->
     <div>查看</div>
    <div  class="prism-player" id="playerContainer" ></div>
  </el-dialog>
</template>

<script setup>
import { ref, reactive, onMounted } from "vue";
const player1 = ref(null);
const isAliplayerLoaded = ref(false)
const opena = () => {
  if (player1.value) {
    // 如果已经创建了,就销毁
    player1.value.dispose();
    player1.value = null;
  }


  player1.value = new Aliplayer({
    id: 'playerContainer',
    source: infoValue.value,
    width: "100%",
    height: "522px",
    ratio: 16 / 9,
    autoplay: true,
    isLive: false,
  }, function (player) {
    console.log("The player is created");
  });
};
const dialogpeopleVisible = ref(false);

const infoValue = ref({});
const openDialog = (bool, info) => {
  console.log(info, "009990999jjggff");
  dialogpeopleVisible.value = bool;
  infoValue.value = info;
};
const handleClose = () => {
  dialogpeopleVisible.value = false;
  player1.value.dispose();
};

defineExpose({ openDialog, handleClose });
</script>
<style lang="scss">
.prism-player{
width:750px;

}
</style>


http://www.kler.cn/news/305806.html

相关文章:

  • 注意!Facebook已移除细分定位排除受众的功能
  • 基于微信小程序的宠物之家的设计与实现
  • 备战软考Day02-数据结构与算法
  • 深度学习| 快速上手深度学习代码的阅读和改写
  • 6.1 溪降技术:绳结
  • 小阿轩yx-Zabbix企业级分布式监控环境部署
  • 期望极大算法(Expectation Maximization Algorithm,EM)
  • 基于SpringBoot的校园新闻网站设计与实现
  • 视觉SLAM ch5——相机与图像
  • AIGC-初体验
  • python 大模型验证码识别
  • C++11的部分新特性
  • Vue路由:Vue router
  • 使用ESP8266和OLED屏幕实现一个小型电脑性能监控
  • 优化深度学习模型训练过程:提升PASCAL VOC 2012数据集上Deeplabv3+模型训练效率的策略
  • 【leetcode-python】最接近的三数之和
  • Acrobat 9 安装教程
  • Redis入门2
  • 驾校预约学习系统的设计与实现
  • 关于决策树的一些介绍
  • 让孩子们动手又动脑,用学优马电子积木,探索电路的奥秘
  • 计算机毕业设计Python深度学习垃圾邮件分类检测系统 朴素贝叶斯算法 机器学习 人工智能 数据可视化 大数据毕业设计 Python爬虫 知识图谱 文本分类
  • Visual Studio安装教程
  • 如何使用ssm实现流浪动物救助站+vue
  • JVM基础概念
  • 深度学习基础--卷积网络
  • Vue安装及环境配置【图解版】
  • leetcode 2576.求出最多标记下标
  • C# 开发教程-中级教程
  • IEEE 754浮点数表示