Support for the experimental syntax ‘decorators-legacy‘ isn‘t currently enabled
作者:互联网
- react 加装饰器需要用babel解析
- 但是用啦很多方法都不管用
- 最后找到啦一个方法
- 可以供参考
//1. 安装依赖
npm i customize-cra react-app-rewired @babel/plugin-proposal-decorators
//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. 重启项目
npm start
标签:babel,Support,currently,enabled,react,start,build,app,rewired 来源: https://blog.csdn.net/lovepink527/article/details/121330226