react配置可使用装饰器语法
作者:互联网
1.安装模块
使用cnpm
cnpm i @babel/plugin-proposal-decorators customize-cra react-app-rewired -D
或者使用yarn
yarn add @babel/plugin-proposal-decorators customize-cra react-app-rewired -D
2.根目录下创建config-overrides.js文件
文件内写入以下代码
// 参考配置连接:https://www.npmjs.com/package/customize-cra
const {override,addDecoratorsLegacy}=require("customize-cra");
module.exports=override(
addDecoratorsLegacy(),//配置装饰器模式
);
3.修改package.json运行命令
"scripts": {
"start": "react-app-rewired start", // update
"build": "react-app-rewired build", // update
"test": "react-app-rewired test", // update
"eject": "react-scripts eject"
},
标签:语法,customize,app,update,react,cra,装饰,rewired 来源: https://blog.csdn.net/qq_41318044/article/details/117773641