【发布时间】:2017-06-02 17:46:18
【问题描述】:
我使用 ES6 的扩展运算符和 Babel 作为 ES5 的转译器。当我像这样使用扩展运算符时:
const { height, weight, radius, ...otherValues } = sphere;
我收到SyntaxError:
ERROR in ./src/sphere.js
Module build failed: SyntaxError: Unexpected token (7:36)
6 |
> 7 | const { height, weight, radius, ...otherValues } = sphere;
| ^
8 |
这是为什么?
【问题讨论】:
-
我已经知道我的问题的答案,但在 StackOverflow 上很难找到答案,所以I'm posting the question and answer I would have found helpful。
-
仅供参考,
...is not an operator。在您的示例中,它是“休息属性”。
标签: javascript ecmascript-6 babeljs