ES6使用babel编译后:IE9 调用父类的构造函数失败
本文介绍了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,显然,最初的问题还是没有解决。
心累啊。。。
解决方案
"plugins": [
"transform-decorators-legacy",
"transform-class-properties",
"transform-es2015-block-scoping",
["transform-es2015-classes", {"loose": true}],
"transform-proto-to-assign",
"transform-es2015-modules-commonjs",
],
这篇关于ES6使用babel编译后:IE9 调用父类的构造函数失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文