我在我的package.json
文件中添加了这两个开发依赖项:
"@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,所以observable是干净的语法,我的文件看起来像这样:
class AppStore {
@observable username = ''
}
export default (new AppStore())
但是一直显示出现这个错误: 我认为我已经正确地完成了,但是无法检测到babel插件是否已加载。