1. npm install mobx mobx-react --save
2. npm install @babel/plugin-proposal-decorators --save
3. npm run eject
package.json中添加
"babel": {
"presets": [
"react-app"
],
"plugins": [
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
]
]
}
way 2: https://www.cnblogs.com/umbrellar/p/10454206.html
react+mobx+antd按需加载 出现Support for the experimental syntax 'decorators-legacy' isn't currently enabled
baidu上面的说法大多是在 项目的package.json 中添加decorators-legacy
因为引入了antd的按需加载 所以只需要在config-overrides.js中添加addDecoratorsLegacy()
const { override, fixBabelImports,addDecoratorsLegacy } = require('customize-cra');
module.exports = override(
fixBabelImports('import', {
libraryName: 'antd',
libraryDirectory: 'es',
style: 'css',
}),addDecoratorsLegacy(),
);