1.安装插件babel-plugin-transform-decorators-legacy
2.npm run eject 弹出react插件
3.package.json中babel上加入"plugins": ["transform-decorators-legacy"]
"babel": {
"presets": [
"react-app"
],
"plugins": [
"transform-decorators-legacy"
]
},
4.
@connect(
state=>({num : state}),
{add , remove , addAsync}
)
后续报错 The 'decorators' plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean
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'.
解决方案