node.js - 运算符 ..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 或其他任何东西来解决不受我控制的模块上的问题?
解决方案
尝试使用@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
更多详细信息,请查看此链接。
推荐阅读
- java - APK 发布问题,一些属性检测为空
- android - 如何为特定口味启动服务?
- java - 升级 JUNIT 5 后无单元测试
- unit-testing - 有没有办法像在 gtest 中一样测试 double 值
- c# - 为什么AES算法会出错
- ios - 按日期分组过滤结果而不将所有内容转储到内存
- sql - SQL 查询,它搜索具有特定数组列项的所有行
- python-3.x - 如何设置通用工作目录?
- ios - 如何设置 Jenkins 来构建使用 Carthage 的 React Native iOS 应用程序?
- graphql - AWS AppSync GraphQL - 使用联合作为突变返回导致错误