所以我无休止地在网上搜索以解决这个问题。
"support for the experimental 'jsx' isn't currently enabled...
Add @babel/preset-react to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-jsx to the 'plugins' section to enable parsing."
Run Code Online (Sandbox Code Playgroud)
所以我有很多(比如 100 个)这样的错误,所以我改变了我的 .babelrc 和 .babel.config.js 看起来像:
{
test: /\.jsx?$/,
exclude: [/node_modules/],
use: [
{
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
'@babel/preset-react',{
'plugins': [
["@babel/plugin-proposal-class-properties", { "loose": true }]
]}]
}
}]}
Run Code Online (Sandbox Code Playgroud)
和配置:
"presets": [
"react",
"@babel/preset-env",
"@babel/preset-typescript",
"@babel/preset-react"
],
"plugins": …Run Code Online (Sandbox Code Playgroud)