我正在尝试在我的react组件中使用require.ensure:
componentDidMount() {
require.ensure([], () => {
require('public/jscripts/brightcove/index.js');
});
}
但不断出现错误:Cannot set property 'default' of undefined
这发生在Brightcove videojs脚本中:
// At this point, `window.videojs` will be the earliest-defined copy of this
// version of videojs.
var videojs = window.videojs;
// https://github.com/videojs/video.js/issues/2698
videojs['default'] = videojs;
有人知道为什么会这样吗?
完整的脚本在这里,我将其保存为本地文件,因此路径为public/jscripts/brightcove/index.js
:https://players.brightcove.net/1752604059001/B1xXFuBodW_default/index.js