我已阅读this tutorial ,而且似乎它对我不起作用,可能是因为它已经过时了。
使用 @inject
装饰时出现以下错误:
./src/index.js
Error: 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'.
如果不使用 TypeScript,我真的找不到正确设置 mobX 装饰的方法吗?
最佳答案
使用 babel 及其插件来转译你的代码。
要使用装饰器,请使用 @babel/plugin-proposal-decorators
在你的 babelrc 文件中添加插件属性:
{
// your other babel settings
"plugins": ["plugin-proposal-decorators"]
}
关于javascript - 在没有 TypeScript 的情况下使用 MobX 装饰器设置 ReactJS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52742117/