使用 create-react-app 设置 Mobx 时的问题

Issues when setting up Mobx with create-react-app

我在使用 React 设置 Mobx 时遇到错误,谁能给我一个简单的步骤?我是 React 的新手,我仍然在研究它附带的文件。

这是我所做的:

这是我遇到的问题:

我试过的:

错误似乎提示我需要在 node_modules\@babel\plugin-proposal-decorators\lib\index.js 中将 legacy 设置为 true。我试过了,但没有用。我在 google 上搜索了这个问题,它似乎是 Babel 7 的问题?

您需要将选项与您在 package.json

中设置的配置一起传递
{
 "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy": true }]
  ]
}

您可以在此处查看文档:https://babeljs.io/docs/en/next/babel-plugin-proposal-decorators.html