Spread 语法在复制 React 组件属性时出错
Spread syntax gives error when copying react component properties
我正在使用 React 并且正在尝试使用扩展语法。出于某种原因,它不起作用并给出错误:
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"]
}
我正在使用 React 并且正在尝试使用扩展语法。出于某种原因,它不起作用并给出错误:
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"]
}