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’.
解决办法:
cnpm install babel-plugin-transform-decorators-legacy --save-dev
cnpm install @babel/plugin-proposal-decorators --save-dev
然后npm run eject 弹出个性化配置
修改babel部分,添加代码
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose" : true }]
]
就ok了
如果用的是vscode有提示报错 “experimentalDecorators”
解决办法:
点击Visual Studio Code左下角的配置按钮(或者文件>首选项>配置),打开用户设置窗口,在搜索框内输入“experimentalDecorators”
"javascript.implicitProjectConfig.experimentalDecorators": false
// 把false改成true 重启编辑器就可以了