Closed westdrug closed 6 years ago
建议均升级到最新版再看看能否复现。
@toxic-johann 你好, 升级版本:
chimee-player v1.4.5;
chimee-plugin-danmu v0.0.9,
还是异步加载后,没有安装成功。 使用 chimee.use 后 报错为:
Uncaught TypeError: You have not installed plugin chimeeDanmu
输出一下这个变量 chimeePluginDanmu
另外 use 是怎么写的
@toxic-johann 输出chimeePluginDanmu 如下图:
此处代码:
require(['chimee-plugin-danmu'], function(chimeePluginDanmu) { console.log('chimeePluginDanmu',chimeePluginDanmu) Chimee.install(chimeePluginDanmu) Chimee.use(chimeePluginDanmu.name) })
—————————————————————————————————————— use 应该是 实例化后调用?, player.use('chimeeDanmu') 此时报了个错误:
Uncaught TypeError: You have not installed plugin chimeeDanmu
也就是说: 使用 require([],func) 异步方式 引入插件,并安装插件。是在 实例化之后才进行的,所以会报: 没有安装 plugin chimeeDanmu
这是我的理解。
use 是实例化后的 chimee
install 是 Chimee 静态对象。现在两个为啥是一样的?
player.use(chimeePluginDanmu.name)
是的, 应该在 实例化后 执行 player.use('chimeeDanmu') 但此时报了个错误:
Uncaught TypeError: You have not installed plugin chimeeDanmu
猜想: 使用 require([],func) 异步方式 引入插件,并安装插件。是在 实例化之后才进行的,异步加载并安装比 player.use('chimeeDanmu') 执行过程 还要迟
用 hasInstalled 查看一下。最好看下能不能提供个类似 codepen 之类的环境。现在你的描述我们这边复现不出来。
@toxic-johann 好,我再自查下,谢谢了!
@toxic-johann 你好,今早看了下, install 后, hasInstalled 没有输出 true或false; use 加了延时, 并打印出 实例化对象中的 $plugins插件集合 里面是包含有 异步加载后并安装的那个插件,并报如下错误:
这是弹幕插件的一个bug 已经修了。 更新一下 chimee-plugin-danmu
@toxic-johann @yandeqiang 可以了!
但: require([],func) 用按需的方式引入 插件模块, 因为模块异步加载,在未加载完成,并未安装时,就已经执行了player.use(), 会报 :
Uncaught TypeError: You have not installed plugin xxx
use 用了 延时,才能正常使用, 但这不是想要的。暂时没有想到改进的办法!
你没安装肯定没法用啊。。。。这个是业务逻辑需要解决的吧
如上标题,如下代码:
require(['chimee-plugin-danmu'], function(chimeePluginDanmu) { console.log('chimeePluginDanmu',chimeePluginDanmu) Chimee.install(chimeePluginDanmu) })
插件异步引入成功,然后安装插件 Chimee.install(chimeePluginDanmu),但没有安装成功。
版本如下:
寻求帮助,谢啦!