Reactjs 支持实验语法';classProperties';isn';t当前已启用(14:13)
我一直在使用react.js,这是第一次发生这种情况,我正在开发一个用parcel bundler设置的应用程序的前端,我在编写简单的jsx代码时遇到了这个问题Reactjs 支持实验语法';classProperties';isn';t当前已启用(14:13),reactjs,jsx,babeljs,Reactjs,Jsx,Babeljs,我一直在使用react.js,这是第一次发生这种情况,我正在开发一个用parcel bundler设置的应用程序的前端,我在编写简单的jsx代码时遇到了这个问题 Support for the experimental syntax 'classProperties' isn't currently enabled (15:13): 13 | } 14 | > 15 | getCars = () => { | ^ 16 |
Support for the experimental syntax 'classProperties' isn't currently enabled (15:13):
13 | }
14 |
> 15 | getCars = () => {
| ^
16 | console.log('hi')
17 | }
我试着安装@babel/plugin建议类属性并设置一个.babelrc文件,正如我在谷歌上搜索错误时看到的那样,但问题是一样的
{
"presets": [
"@babel/preset-react"
],
"plugins": [
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
]
]
}
我也有同样的问题 package.json
"devDependencies": {
"@babel/core": "7.0.0",
"@babel/plugin-proposal-class-properties": "7.0.0",
"@babel/plugin-proposal-decorators": "7.0.0"
...
}
B.法律改革委员会
{
"presets": ["@babel/preset-react", "@babel/preset-env"],
"plugins": [
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
]
]
}
我也有同样的问题 package.json
"devDependencies": {
"@babel/core": "7.0.0",
"@babel/plugin-proposal-class-properties": "7.0.0",
"@babel/plugin-proposal-decorators": "7.0.0"
...
}
B.法律改革委员会
{
"presets": ["@babel/preset-react", "@babel/preset-env"],
"plugins": [
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
]
]
}
这是解决方案吗?仅仅为了让包裹正常工作而添加
.babelrc
是没有意义的。这是一个包裹问题,应该由包裹处理,因为他们说这是零配置,所以默认情况下这应该可以工作。我还尝试将.babelrc添加到我的项目中,但我不断收到越来越多的错误(因为我使用了React、TypeScript和其他库)。这是解决方案吗?仅为包裹工作而添加.babelrc
是没有意义的。这是一个包裹问题,应该由包裹处理,因为他们说这是零配置,所以默认情况下这应该可以工作。我还尝试将.babelrc添加到我的项目中,但我不断地遇到越来越多的错误(因为我使用了React、TypeScript和其他库)。