【发布时间】:2018-11-21 10:00:28
【问题描述】:
我在package.json 中添加了这两个 devDependencies:
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-decorators": "^7.1.6",
在.babelrc 一个文件中,我已将它们添加为插件:
{
"presets": ["module:metro-react-native-babel-preset"],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true}],
["@babel/plugin-proposal-class-properties", { "loose": true}]
]
}
我正在使用 mobx,所以可以观察到干净的语法,我的文件如下所示:
class AppStore {
@observable username = ''
}
export default (new AppStore())
但它总是显示这个错误:
我想我已经做对了,但是没有办法检测是否加载了 babel 插件。
【问题讨论】:
-
在 babel 沙箱 babeljs.io/repl 这两个插件也无法加载。
标签: javascript reactjs react-native babeljs