create-react-app mobx 不支持 修饰器

1.npm run eject (返编译)
2.npm i (全部重新安装依赖)
3.npm install --save-dev babel-plugin-transform-decorators-legacy (安装该模块中间可能有告警自行消除即可)
4.npm install @babel/plugin-proposal-decorators
5.在 package.json 里修改 babel 如下所示
"babel": {
"plugins":[

[
  "@babel/plugin-proposal-decorators",
  {
    "legacy":true
  }
],
[
  "@babel/plugin-proposal-class-properties",
  {
    "loose":true
  }
]

],
"presets":[

"react-app"

]
},
6npm start就可以了

你可能感兴趣的:(mobx,react.js,javascript)