ES6使用babel编译后:IE9 调用父类的构造函数失败

IE9 和 IE10。原因是 ocs 实例创建失败,因为没有调用父类的构造函数。
在github上找到解决方案:super() not calling parent's constructor on IE9
实践之后:

{
  "plugins": [
    ["transform-es2015-classes", {"loose": true}],
    "transform-proto-to-assign",
    "transform-decorators-legacy"
  ],
  "presets": [
    "es2015",
    "react",
    "stage-0"
  ]
}

又碰到了下面的问题。

ERROR in ./js/kill/order/index.js
Module build failed: SyntaxError: C:/Users/Administrator/Desktop/ydh-qiang-web/src/main/webapp/pc/js/kill/order/index.js: Missing class properties transform.
  23 |     }
  24 |
> 25 |     state = {
     |     ^
  26 |         loading: false,

加上transform-class-properties插件后,编译倒是能通过了,但this.props还是undefined,显然,最初的问题还是没有解决。
心累啊。。。

阅读 4.4k
2 个回答
"plugins": [
    "transform-decorators-legacy",
    "transform-class-properties",
    "transform-es2015-block-scoping",
    ["transform-es2015-classes", {"loose": true}],
    "transform-proto-to-assign",
    "transform-es2015-modules-commonjs",
  ],
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进