Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在没有TypeScript的情况下使用MobX装饰器设置ReactJS?_Javascript_Reactjs_Typescript_Mobx - Fatal编程技术网

Javascript 在没有TypeScript的情况下使用MobX装饰器设置ReactJS?

Javascript 在没有TypeScript的情况下使用MobX装饰器设置ReactJS?,javascript,reactjs,typescript,mobx,Javascript,Reactjs,Typescript,Mobx,我读过,它似乎不适合我,可能是因为它过时了 使用@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,

我读过,它似乎不适合我,可能是因为它过时了

使用
@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和它的插件来传输代码

使用装饰者使用

在babelrc文件中,添加插件属性:

{
  // your other babel settings
  "plugins": ["plugin-proposal-decorators"]
}

当我安装该npm时,没有创建babelrc文件?没有。请查看如何设置.babelrc文件以及您可能需要的软件包。可能您需要babel core、babel loader、babel preset env、babel preset react。另外,看看如何设置网页包。这里有很多教程,我相信你一定能找到答案。这是MobX文档页面,介绍了你想做的事情: