Javascript 带Babel的静态类属性上的SyntaxError

Javascript 带Babel的静态类属性上的SyntaxError,javascript,babeljs,ecmascript-next,Javascript,Babeljs,Ecmascript Next,我正在尝试使用ES2016语法创建一个组件,如下所示: export default class { static defaultProps = { color: '#cc7f29', } } 我相信staticdefaultprops={}语法是ES2016的一部分,所以我将ES2016预置加载到了Babel中。我已经安装了babel-preset-es2016 这会导致编译错误: Module build failed: SyntaxError: Unexpected to

我正在尝试使用ES2016语法创建一个组件,如下所示:

export default class {
  static defaultProps = {
    color: '#cc7f29',
  }
}
我相信
staticdefaultprops={}
语法是ES2016的一部分,所以我将ES2016预置加载到了Babel中。我已经安装了
babel-preset-es2016

这会导致编译错误:

Module build failed: SyntaxError: Unexpected token (10:22)

   8 | export default class extends React.Component {
   9 | 
> 10 |   static defaultProps = {
     |                       ^
  11 |     color: '#cc7f29',
  12 |     theme: 'light',
  13 |   }

BabelLoaderError: SyntaxError: Unexpected token (10:22)

   8 | export default class extends React.Component {
   9 | 
> 10 |   static defaultProps = {
     |                       ^
  11 |     color: '#cc7f29',
  12 |     theme: 'light',
  13 |   }

我做错了什么?

类属性是ECMAScript stage 2提案,所以您需要包括

使用“阶段0预设”也有效,因为它包括所有以前的阶段预设。

如果阅读说明,则可以看到公共类字段不属于该修订版。