P.B*_*key 4 javascript reactjs babeljs
我升级反应通天5项目巴贝尔6码是从pluralsight在github上.app.js上发生错误.我假设有一个插件需要升级,允许这种语法工作:
export default class DriftApp extends React.Component {
state = {//builder is not happy with this equals sign, unexpected token
showIndex: 0,
numSlides: 5
}
Run Code Online (Sandbox Code Playgroud)
这是哪个插件?
这是我的package.json:
"homepage": "https://github.com/jaketrent/react-drift#readme",
"devDependencies": {
"autobind-decorator": "^1.3.3",
"babel-core": "^6.5.1",
"babel-loader": "^6.2.2",
"babel-plugin-react-transform": "^2.0.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.5.0",
"babel-preset-react": "^6.5.0",
"express": "^4.13.3",
"file-loader": "^0.8.4",
"radium": "^0.16.6",
"react": "^0.14.2",
"react-dom": "^0.14.2",
"react-hot-loader": "^2.0.0-alpha-4",
"react-tools": "^0.10.0",
"react-transform": "0.0.3",
"react-transform-catch-errors": "^1.0.0",
"react-transform-hmr": "^1.0.1",
"redbox-react": "^1.1.1",
"webpack": "^1.12.2",
"webpack-dev-middleware": "^1.2.0",
"webpack-hot-middleware": "^2.4.1"
}
}
Run Code Online (Sandbox Code Playgroud)
您在代码中使用属性初始值设定项语法,这是一个实验性功能(提案).您可以通过安装babel-plugin-transform-class-properties模块将其转换为ES5
npm install babel-plugin-transform-class-properties --save-dev
Run Code Online (Sandbox Code Playgroud)
将以下行添加到.babelrc文件中:
{
"plugins": ["transform-class-properties"]
}
Run Code Online (Sandbox Code Playgroud)
参考https://babeljs.io/docs/plugins/transform-class-properties/
| 归档时间: |
|
| 查看次数: |
1013 次 |
| 最近记录: |