[英]Class constructor super() doesn't work in IE
Today I found out the hard way that babel doesn't compile classes to work with IE.今天我发现了 babel 不编译类以与 IE 一起工作的艰难方法。 There's a running babel issue here .
这里有一个正在运行的 babel 问题。 However I've tried a lot of the solutions in that issue with no luck.
但是,我在该问题上尝试了很多解决方案,但都没有运气。
My current .babelrc
file looks like this.我当前的
.babelrc
文件看起来像这样。
{
"plugins": [
"transform-runtime",
"transform-regenerator",
"syntax-async-functions"
],
"presets": [
"es2015",
"react",
"stage-2"
]
}
I cant get something as simple as this running in IE.我无法在 IE 中运行像这样简单的东西。
class Main {
constructor(props) {
console.log(props.apple)
}
}
class Test extends Main {
constructor(props) {
super(props)
console.log(this.apple)
}
}
new Test({apple: 'pie'})
I tested on IE10 (10.0.9200.17228) running from Windows 8.我在从 Windows 8 运行的 IE10 (10.0.9200.17228) 上进行了测试。
es2015-loose
works! es2015-loose
作品! I wasn't updating the babel configuration in my webpack.config.js
I was updating it in my .babelrc
.我没有更新我的巴贝尔配置
webpack.config.js
我正在更新它在我的.babelrc
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.