Support for the experimental syntax 'decorators-legacy' isn't currently enab -- 装饰器@

You have to endure a long pause, Baidu a lot of ways, including, Tim configuration file, modify the file package.json ,, try a lot anyway, have tried in a project, and finally this did not hold much hope ,, actually good , and

 

The reason is certainly not equipped to support the cause of Component decorator

@connect('age')

Before a lot of plug-in installed

 

Also add a file config-overrides.js

/* config-overrides.js */
const { useBabelRc, override, addDecoratorsLegacy } = require('customize-cra')

const config = override(addDecoratorsLegacy())
// const config = override(useBabelRc())
module.exports = configs

 

No good. . .

Then performed according to the following

1、 npm run eject

2, find bebel property in package.json file, modify the restart

"babel": {
    "plugins": [
      [
        "@babel/plugin-proposal-decorators",
        {
          "legacy": true
        }
      ]
    ],
    "presets": [
      "react-app"
    ]
  },

ok friends

 

Refer to the original https://blog.csdn.net/qq_41831345/article/details/101287368

 

Guess you like

Origin www.cnblogs.com/slightFly/p/12008516.html