如何支持decorators属性
1. vscode支持decorators
方法1):设置vscode
方法2):添加jsconfig.json支持experimentalDecorators
{
"compilerOptions": {
"target": "esnext",
"experimentalDecorators": true
},
"exclude": ["node_modules"]
}
2. create-react-app支持decorators
报错截图如下:
在package.json中添加babel配置:
"babel": {
"presets": [
"react-app"
],
"plugins": [
[
"@babel/plugin-proposal-decorators",
{ "legacy": true }
]
]
}