安装完
npm install babel-plugin-transform-decorators-legacy -D
配置完
"babel": {
"presets": [
"react-app"
],
"plugins": ["transform-decorators-legacy"]
},
运行
npm run start
报错
The ‘decorators’ plugin requires a ‘decoratorsBeforeExport’ option, whose value must be a boolean. If you are migrating from Babylon/Babel 6 or want to use the old
decorators proposal, you should use the ‘decorators-legacy’ plugin instead of ‘decorators’.
尝试解决:无效
npm i roadhog@2.5.0-beta.1
尝试解决:有效
"babel": {
"presets": [
"react-app"
],
"plugins": [ ["@babel/plugin-proposal-decorators", { "legacy": true }]]
},