我在React演示中使用Babel和Webpack。静态类属性的编译失败,函数调用为对象值。但对普通类型很好。
ERROR in ./src/components/productSet.jsx
Module build failed: SyntaxError: /Users/jack/demo/src/components/productSet.jsx: Unexpected token (9:35)
7 | static propTypes: {
8 | test: React.PropTypes.object,
> 9 | data: React.PropTypes.oneOf(['News', 'Photos']),
| ^
10 | }
BTW,我启用了所有0-3阶段功能
module: {
loaders: [{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react', 'stage-3', 'stage-2', 'stage-1', 'stage-0']
}
}]
},
答案 0 :(得分:1)
与static prototypes
不同,=
后跟:
而不是static propTypes= {
尝试:
static propTypes: {
代替def insertIntoDB(task: Task) {
DB.withConnection { implicit c =>
SQL("insert into task (id, name, description, groupname) values ({task.id, task.name, task.description, task.group})").on(
'id -> task.id,
'name -> task.name,
'description -> task.description,
'groupname -> task.group
).executeUpdate()
}
}