为什么它不接受传播属性?我正在使用 babel-preset-env 。
.babelrc
{
"presets": [
"react",
[
"env",
{
"targets": {},
"debug": true,
"modules": "commonjs"
}
]
]
}
的package.json
{
"name": "myapp",
"version": "0.1.0",
"main": "index.js",
"private": true,
"dependencies": {
"babel-core": "6.25.0",
"babel-loader": "7.1.1",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"extract-text-webpack-plugin": "3.0.0",
"file-loader": "0.11.2",
"html-webpack-plugin": "^2.30.1",
"moment": "^2.18.1",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-router": "^4.1.2",
"react-router-dom": "^4.1.2",
"redux": "^3.7.2",
"redux-form": "^7.0.3",
"style-loader": "0.18.2",
"url-loader": "0.5.9",
"webpack": "3.5.1",
"webpack-dev-server": "2.7.1",
"webpack-node-externals": "^1.6.0"
},
"scripts": {
"start": "",
"build": "webpack"
}
}
答案 0 :(得分:6)
Object rest spread
运算符可能可能是 ECMAScript规范的未来功能(暂时处于第3阶段)。
目前,感谢Babel
可以支持它,但您必须使用transform-object-rest-spread plugin
。
{
"presets": [
"react",
[
"env",
{
"targets": {},
"debug": true,
"modules": "commonjs"
}
],
"transform-object-rest-spread"
]
}