video.js在Internet Explorer中引发InvalidStateError

在IE11中使用video.js,播放器无法加载视频片段。

如果我在控制台中查看,则会看到“ InvalidStateError”错误。

违规行位于xhr程序包的video.js库依赖项中:

// node_modules/video.js/node_modules/xhr/index.js#L210
|  if ("responseType" in options) {
>     xhr.responseType = options.responseType
|  }

如果我在计算机上手动删除此行,则播放器将正常工作。

我该如何解决?我正在使用webpack构建应用程序。

stkelvinlee 回答:video.js在Internet Explorer中引发InvalidStateError

这很hacky,但是您可以使用webpack-plugin-replace plugin通过将行替换为空字符串来删除该行。

// fixes "InvalidStateError" in IE which occurs at:
// node_modules/video.js/node_modules/xhr/index.js#L210
new ReplacePlugin({
  include: [
    "/node_modules/video.js/node_modules/xhr/index.js"
  ],patterns: [
    {
      regex: /xhr\.responseType = options\.responseType/,value: ''
    }
  ],// required due to a bug in `webpack-plugin-replace`
  // see: https://github.com/lukeed/webpack-plugin-replace/issues/6
  values: {
    "": ""
  }
})
本文链接:https://www.f2er.com/3123374.html

大家都在问