小编meh*_*meh的帖子

当前未启用对实验性“jsx”的支持

所以我无休止地在网上搜索以解决这个问题。

"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)

jsx reactjs webpack babeljs

23
推荐指数
2
解决办法
2万
查看次数

标签 统计

babeljs ×1

jsx ×1

reactjs ×1

webpack ×1