require引用video.js报错,出现global/window提示

想用requirejs引入video.js(7.7.3),结果却报错了,get请求文件404:
....../global/window.js net::ERR_ABORTED 404 (Not Found)
....../global/document.js net::ERR_ABORTED 404 (Not Found)
然后就是相关内容报错:
require.js:8 Uncaught Error: Script error for: global/window
require.js:8 Uncaught Error: Script error for: global/document
网上找不到相关的问题,在github上找到相关问题,但是看不明白云里雾里,求个详细的解决方案

阅读 6k
1 个回答

折腾半天自力更生解决了,在video.js中,需要给定window和document对象:

(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('global/window'), require('global/document')) :
  typeof define === 'function' && define.amd ? define(['libs/video/global/window', 'libs/video/global/document'], factory) :
  (global = global || self, global.videojs = factory(global.window, global.document));
}(this, function (window$1, document) { 'use strict';

  window$1 = window$1 && window$1.hasOwnProperty('default') ? window$1['default'] : window$1;
  document = document && document.hasOwnProperty('default') ? document['default'] : document;

上面一串代码和引用文件就是为了让window$1和document两个变量获取window和document对象,只要让两个变量对应上即可,详见我的个人笔记

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题