Support for the experimental syntax ‘decorators-legacy‘ isn‘t currently enabled (52:1)

在react中写装饰器的报的错,

 解决办法

1 先安装

  npm install customize-cra react-app-rewired @babel/plugin-proposal-decorators --save

2 在项目的根目录下新建config-overrides.js文件

Support for the experimental syntax ‘decorators-legacy‘ isn‘t currently enabled (52:1)_第1张图片

加入以下代码

const { override, addDecoratorsLegacy } = require('customize-cra');
module.exports = override(
 addDecoratorsLegacy()
 );

3 修改package.json文件

"scripts": {
 "start": "react-app-rewired start",
 "build": "react-app-rewired build",
 "test": "react-app-rewired test",
 "eject": "react-app-rewired eject"
  },

4 重启

你可能感兴趣的:(react,reactjs)