我已经读过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设置装饰的方法吗?
答案 0 :(得分:1)
使用babel及其插件来翻译您的代码。
要使用装饰器,请使用@babel/plugin-proposal-decorators
在您的babelrc文件中添加plugins属性:
{
// your other babel settings
"plugins": ["plugin-proposal-decorators"]
}