Docusaurus因IE失败:对象不支持属性或方法“分配" [英] Docusaurus fails with IE: Object doesn't support property or method 'assign'

查看:142
本文介绍了Docusaurus因IE失败:对象不支持属性或方法“分配"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在建立V2 Docusaurus网站: https://www.10studio.tech .

We are making a V2 Docusaurus website: https://www.10studio.tech.

我们刚刚意识到,它在IE11(例如IE11)中不能很好地工作.错误消息是:Object doesn't support property or method 'assign'.

We have just realized that it does not work well in IE, for instance, IE11. The error message is: Object doesn't support property or method 'assign'.

有一些提供IE兼容性的软件包,例如core-js,但是我们不知道如何正确地将其添加到Docusaurus v2中.

There are some packages to provide with IE compatibility such as core-js, but we don't know how to properly add it to Docusaurus v2.

有人知道如何修改吗?

推荐答案

错误消息告诉您该对象没有assign function. assignfunction,您正在谈论的浏览器显然不支持它,因此您需要 polyfill .一个很好的例子是:

The error message is telling you that object doesn't have an assign function. assign is a function which apparently is not supported in the browser you are speaking about, so you need to polyfill it. A good example is:

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

但是,即使这可以解决您所抱怨的问题,也很有可能还会发生其他问题.您可能还需要填充其他内容,您可能想看看 BabelJS 来实现此目的

However, even though this will fix the problem you were complaining about, it is highly probable that other problems will occur as well. You might need to polyfill some other stuff as well, you might want to take a look into BabelJS in order to achieve this.

这篇关于Docusaurus因IE失败:对象不支持属性或方法“分配"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆