在没有 TypeScript 的情况下使用 MobX 装饰器设置 ReactJS?
Setting up ReactJS with MobX decorators without TypeScript?
我读过 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"]
}
我读过 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"]
}