我们正在制作 V2 Docusaurus 网站:https ://www.10studio.tech 。
我们刚刚意识到它在 IE 中效果不佳,例如 IE11。错误信息是:Object doesn't support property or method 'assign'。
有一些包提供 IE 兼容性,例如core-js,但我们不知道如何将其正确添加到 Docusaurus v2。
有谁知道如何修改这个?
我们正在制作 V2 Docusaurus 网站:https ://www.10studio.tech 。
我们刚刚意识到它在 IE 中效果不佳,例如 IE11。错误信息是:Object doesn't support property or method 'assign'。
有一些包提供 IE 兼容性,例如core-js,但我们不知道如何将其正确添加到 Docusaurus v2。
有谁知道如何修改这个?
错误消息告诉您该对象没有assign function. assign是function这显然不是在你谈论的浏览器所支持,所以你需要填充工具它。一个很好的例子是:
if (!Object.assign) {
  Object.defineProperty(Object, 'assign', {
    enumerable: false,
    configurable: true,
    writable: true,
    value: function(target) {
      'use strict';
      if (target === undefined || target === null) {
        throw new TypeError('Cannot convert first argument to object');
      }
      var to = Object(target);
      for (var i = 1; i < arguments.length; i++) {
        var nextSource = arguments[i];
        if (nextSource === undefined || nextSource === null) {
          continue;
        }
        nextSource = Object(nextSource);
        var keysArray = Object.keys(Object(nextSource));
        for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
          var nextKey = keysArray[nextIndex];
          var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
          if (desc !== undefined && desc.enumerable) {
            to[nextKey] = nextSource[nextKey];
          }
        }
      }
      return to;
    }
  });
}
可以在这里找到:https : //gist.github.com/spiralx/68cf40d7010d829340cb
但是,即使这可以解决您所抱怨的问题,也很可能会出现其他问题。您可能还需要 polyfill 其他一些东西,您可能需要查看BabelJS以实现这一点。