webpack打包时报错:Support for the experimental syntax 'classProperties' isn't currently enabl

Posted 浮华夕颜

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了webpack打包时报错:Support for the experimental syntax 'classProperties' isn't currently enabl相关的知识,希望对你有一定的参考价值。

在写react项目创建class时使用了静态属性,但是在打包的时候报错:

 根据报错提示下载@babel/plugin-proposal-class-properties包,并在.babelrc文件中的"plugins"里添加一项"@babel/plugin-proposal-class-properties"

{
    "presets": ["@babel/preset-env", "@babel/preset-react"],
    "plugins": ["@babel/plugin-transform-runtime","@babel/plugin-proposal-class-properties"]
}

重新打包即可。

以上是关于webpack打包时报错:Support for the experimental syntax 'classProperties' isn't currently enabl的主要内容,如果未能解决你的问题,请参考以下文章