babel-preset-env语法错误:带有传播属性的意外标记 [英] babel-preset-env SyntaxError: Unexpected token with spread properties

查看:132
本文介绍了babel-preset-env语法错误:带有传播属性的意外标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么不接受点差属性?我正在使用 babel-preset-env

Why its not accepting spread properties ? I am using babel-preset-env for this.

.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"
  }
}


推荐答案

对象休息传播 运营商将可能成为ECMAScript的未来功能规范(暂时在第3阶段)。

The Object rest spread operator will probably be a future feature of an ECMAScript specification (it's in stage 3 for the moment).

现在,由于 Babel 但你必须使用 转换 - object-rest-spread插件

For now, it can be supported thanks to Babel but you have to use the transform-object-rest-spread plugin.

{
    "presets": [
        "react",
        [
            "env",
            {
                "targets": {},
                "debug": true,
                "modules": "commonjs"
            }
        ],
        "transform-object-rest-spread"
    ]
}

这篇关于babel-preset-env语法错误:带有传播属性的意外标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆