【问题标题】:operator ..props not working on Microsoft Edge [ 41.16299.1480.0 ]运算符 ..props 不适用于 Microsoft Edge [41.16299.1480.0]
【发布时间】:2020-01-17 16:59:11
【问题描述】:

从这个讨论开始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 或其他任何东西来解决不受我控制的模块上的问题?

pre-build-optimizer 阶段似乎有问题..

【问题讨论】:

    标签: node.js angular babeljs microsoft-edge polyfills


    【解决方案1】:

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

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

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

    那么,请参考以下方法使用:

    • 带配置文件(推荐)

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

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

    更多详细信息,请查看this link

    【讨论】:

      猜你喜欢
      • 2019-02-15
      • 2017-06-30
      • 2023-01-14
      • 1970-01-01
      • 1970-01-01
      • 2016-12-04
      • 1970-01-01
      • 1970-01-01
      • 2016-09-12
      相关资源
      最近更新 更多