为什么我的巴别塔填充物不工作
Why does my babel poyfill is not working?
我的webpack配置如下:
var Path = require('path');
module.exports = {
entry: {
create: ['babel-polyfill', Path.resolve(__dirname, "./src/create.js")],
},
output: {
path: Path.resolve(__dirname, "../../public/crm/js/"),
filename: '[name].js'
},
module: {
loaders: [
{
test: /'.js$/,
exclude: /node_modules/,
loader: 'babel-loader?presets[]=es2015,presets[]=react'
}
]
}
}
我还npm安装这些模块:
"babel-core": "^6.17.0",
"babel-loader": "^6.2.5",
"babel-polyfill": "^6.16.0",
"babel-preset-es2015": "^6.13.2",
"babel-preset-react": "^6.16.0"
下面是我的create。js文件:
import "babel-polyfill";
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
export default class Select extends Component {
//some code
onKeyDown = (e) => {
const {values} = this.props
const idx = values.indexOf(this.state.selection)
if (e.keyCode === 38 && idx > 0) { /* up */
this.setState({
selection: values[idx - 1]
})
} else if (e.keyCode === 40 && idx < values.length -1) { /* down */
this.setState({
selection: values[idx + 1]
})
}
this.fireOnSelect()
}
//some code
}
下面是来自控制台的错误信息:
ERROR in ./src/create.js
Module build failed: SyntaxError: Unexpected token (36:12)
34 | }
35 |
> 36 | onKeyDown = (e) => {
| ^
37 | const {values} = this.props
38 | const idx = values.indexOf(this.state.selection)
39 | if (e.keyCode === 38 && idx > 0)
我做错什么了吗?我没有正确设置巴别尔复方药吗?
您需要使用额外的Babel插件来支持类属性:transform-class-properties
(或者,安装stage-1
或stage-2
预设)
相关文章:
- 谷歌表单-根据分配给谷歌应用程序的工作为商业用户预先填充多项选择列表
- AngularJS绑定没有'在没有填充父范围的情况下无法工作
- 如何在HTML / CSS中填充垂直和滚动中间窗格(Chrome可以工作,但不能Firefox)
- (X-Editable)与(Select2标签)不工作,可以't填充当前标签并跟踪添加/删除的标签
- 我正试图获得一个带有复选框的多选下拉列表,在填充项目和获得所有选中的工作时遇到了一些问题
- jQuery表单填充器不工作
- 我正在用来自选择的数据填充文本框,它可以工作,但是
- 未在IE中填充的列表框在FF和Chrome中工作
- Backbonejs 集合未填充,但获取工作
- 为什么这个下拉菜单没有填充工作链接
- 我可以使用excanvas或类似的画布填充程序让impact js在IE7和/或8中工作吗
- Javascript洪水填充功能只能部分工作[扫雷]
- IE7中没有填充mootools中的动态下拉列表.IE8工作良好
- 如果填充了三个输入并且两个特定的输入相等,则会更改按钮样式;除非不删除“不等于”输入的值,否则它可以工作
- 自动填充脚本不工作
- IE7,8悬停状态不工作时,使用下划线模板填充html
- AJAX填充文本框不工作
- 各种calc()填充库在IE8中不工作
- 为什么我的巴别塔填充物不工作
- 在Google工作表中编辑前一个单元格时自动填充日期