首页 > 解决方案 > 运算符 ..props 不适用于 Microsoft Edge [41.16299.1480.0]

问题描述

从这个讨论开始Edge: SCRIPT1028: Expected identifier, string or number我不知道如何使用 babel 解决问题。我面临的问题是在我正在使用的模块(不是我的类)内部,所以我无法(轻松地)对代码进行修补。

我正在导入一个类:

import { Class1 } from '@eds/vanilla';   <-- This is not mine

that his then importing another class 

./src/public/eds-components/charts/bar-charts/Class1.js

That is importing :
import { ColorScale } from '../common/ColorScale';


export class ColorScale {

  /**
   * Setup color scale properties
   * @param {Object} props - The properties to initialize the color scale
   * @param {Array} props.colors - The array of colors
   */
  constructor(props) {
    props = {
      ...props
    };
    this.length = props.length || 15;
    this.colors = props.colors || this.generateColorMatrix(this.length);
  }

如何使用 babel/polyfills 或其他任何东西来解决不受我控制的模块上的问题?

预构建优化器阶段似乎存在问题.. 在此处输入图像描述

标签: node.jsangularbabeljsmicrosoft-edgepolyfills

解决方案


尝试使用@babel/plugin-proposal-object-rest-spread插件。

使用以下命令安装此插件:

npm install --save-dev @babel/plugin-proposal-object-rest-spread

然后,参考以下方法来使用它:

  • 带配置文件(推荐)

    {
       "plugins": ["@babel/plugin-proposal-object-rest-spread"]
    }
    
  • 通过 CLI

    babel --plugins @babel/plugin-proposal-object-rest-spread script.js
    

更多详细信息,请查看此链接


推荐阅读