当前位置: 代码迷 >> 综合 >> Support for the experimental syntax ‘decorators-legacy‘ isn‘t currently enabled (52:1)
  详细解决方案

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

热度:70   发布时间:2023-12-15 05:15:20.0

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

 解决办法

1 先安装

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

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

加入以下代码

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 重启

  相关解决方案