我正在使用react,我正在尝试使用spread语法。由于某种原因它不起作用,它给出了一个错误:
const { className, children, ...otherprops } = this.props;
知道我做错了什么吗?
你得到Unexpected token
因为你缺少一个babel预设,stage-0
Without stage-0, it doesn't work
为了添加它,你必须
1º安装它
npm install --save-dev babel-preset-stage-0
2º将它添加到.babelrc
{
"presets": ["react","es2015","stage-0"]
}