1

我在节点/浏览器上玩传播语法。

 console.log([{ name: "herry" }, { age: "10" }].reduce((acc, cur) => ({...cur,...acc})))

1) 使用 nodejs v6.10,

SyntaxError: Unexpected token ...

2) 铬 50

SyntaxError: Unexpected token ...

3)babel stage-0,它运行良好。

我只是在徘徊为什么它不能在节点 6.10 上运行,因为它对于传播操作都是绿色的。

http://node.green/

4

1 回答 1

2

要使其正常工作:

yarn add -D babel-plugin-transform-object-rest-spread # (or the npm equivalent)

然后将“transform-object-rest-spread”添加到您的 .babelrc 插件中,例如

{
  "presets": ["es2015"],
  "plugins": ["transform-object-rest-spread"]
}
于 2017-04-06T13:39:32.233 回答