简体   繁体   中英

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. There's a running babel issue here . However I've tried a lot of the solutions in that issue with no luck.

My current .babelrc file looks like this.

{
  "plugins": [
    "transform-runtime",
    "transform-regenerator",
    "syntax-async-functions"
  ],
  "presets": [
    "es2015",
    "react",
    "stage-2"
  ]
}

I cant get something as simple as this running in 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.

es2015-loose works! I wasn't updating the babel configuration in my webpack.config.js I was updating it in my .babelrc .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM