本文介绍了SyntaxError:缺少类属性转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对babel转换有疑问.在我的React容器中添加handle事件后,出现此错误.
I have problem with babel transform. After add handle event in my React container i got this error.
SyntaxError:缺少类属性转换.
SyntaxError: Missing class properties transform.
21 | // handlers
22 |
> 23 | onIncrement = () => {
| ^
24 | const { dispatch } = this.props;
25 |
26 | dispatch(valueDecrement())
我的.babelrc
My .babelrc
{
"presets": [
[
"@babel/env",
{
"targets": {
"browsers": [
"last 2 versions"
]
}
}
],
"@babel/react",
"@babel/typescript",
],
}
我的webpack加载器
My webpack loader
...
module: {
rules: [
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
],
},
...
推荐答案
解决.需要安装@ babel/plugin-proposal-class-properties并将此插件添加到.babelrc中.链接
Solve. Need to install @babel/plugin-proposal-class-properties and add this plugin to the .babelrc.Link
这篇关于SyntaxError:缺少类属性转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!