目前未启用对实验语法“ classProperties”的支持(14:13)

我一直在使用react.js,这是第一次发生,正在开发使用parcel-bundler设置的应用程序的前端,当我编写简单的jsx代码时遇到了这个问题。

Support for the experimental syntax 'classproperties' isn't currently enabled (15:13):
  13 |     }
  14 | 
> 15 |     getcars = () => {
     |            ^
  16 |         console.log('hi')
  17 |     }

我尝试安装@ babel / plugin-proposal-class-properties并设置一个.babelrc文件,如我在Google搜索错误但同样的问题时所看到的那样

{
    "presets": [
        "@babel/preset-react"
    ],"plugins": [
        [
            "@babel/plugin-proposal-class-properties",{
                "loose": true
            }
        ]
    ]
}
gavin_array 回答:目前未启用对实验语法“ classProperties”的支持(14:13)

我遇到了同样的问题。

package.json

  "devDependencies": {
    "@babel/core": "7.0.0","@babel/plugin-proposal-class-properties": "7.0.0","@babel/plugin-proposal-decorators": "7.0.0"
...
  }

.babelrc

{
  "presets": ["@babel/preset-react","@babel/preset-env"],"plugins": [
    [
      "@babel/plugin-proposal-decorators",{
        "legacy": true
      }
    ],[
      "@babel/plugin-proposal-class-properties",{
        "loose": true
      }
    ]
  ]
}

本文链接:https://www.f2er.com/3129144.html

大家都在问