我正在尝试使用mobx装饰器,之前在React native上安装和使用它都没有问题,但是现在我正在使用React.Js库开发一个网站,它给了我这个错误。
Support for the experimental syntax 'decorators-legacy' isn't currently enabled (25:1):
23 |
24 |
> 25 | @observer
| ^
26 | class Recomended extends Component{
27 | constructor(props) {
28 | super(props);
任何人都可以帮助使其正常工作。
下面是我的包裹。杰森:
{
"name": "airingbot",
"version": "0.1.0",
"private": true,
"dependencies": {
"@createjs/tweenjs": "^2.0.0-beta.4",
"babel-plugin-mobx-deep-action": "^1.6.1",
"es6-tween": "^5.5.10",
"mobx": "^5.14.2",
"mobx-react": "^6.1.4",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-scripts": "3.1.2",
"three-orbit-controls": "^82.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"babel": {
"plugins": [
"transform-decorators-legacy",
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
"presets": [
"react-app"
]
},
"devDependencies": {
"babel-plugin-transform-decorators-legacy": "^1.3.5"
}
}
答案 0 :(得分:0)
我认为这些步骤可能有助于向使用{ "_id" : ObjectId("5db21090d15e418f2d5b7b4e"), "value" : 3, "date" : ISODate("2019-05-03T12:01:07Z") }
{ "_id" : ObjectId("5db21090d15e418f2d5b7b4f"), "value" : 4, "date" : ISODate("2019-05-04T12:07:07Z") }
{ "_id" : ObjectId("5db21090d15e418f2d5b7b53"), "value" : 5, "date" : ISODate("2019-05-05T12:01:07Z") }
{ "_id" : ObjectId("5db21090d15e418f2d5b7b54"), "value" : 6, "date" : ISODate("2019-05-06T12:01:07Z") }
{ "_id" : ObjectId("5db21090d15e418f2d5b7b55"), "value" : 7, "date" : ISODate("2019-05-07T12:01:07Z") }
创建的React应用程序中添加装饰器支持:
create-react-app
npm install --save-dev react-app-rewired babel-plugin-transform-decorators-legacy
中用react-scripts
替换react-app-rewired
package.json
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
...
}
,然后复制下一个内容:config-overrides.js