我无法在我的管道中加入SOMECAR
。是否有扩散运营商的替代方案?
我正在尝试编译以下代码,它会产生语法错误:
SOMEAWARD
答案 0 :(得分:1)
使用lodash.omit:
const PrivateRoute = (props) => {
const Component = props.component;
const rest = omit(props, ['component'])
return (
<Route
{...rest}
render={props =>
fakeAuth.isAuthenticated ? (
<Component {...props} />
) : (
<Redirect
to={{
pathname: "/login",
state: { from: props.location }
}}
/>
)
}
/>
);
}
答案 1 :(得分:1)
安装babel-plugin-transform-object-rest-spread
npm install --save-dev babel-plugin-transform-object-rest-spread
在.babelrc文件中,添加以下行
{
"plugins": ["transform-object-rest-spread"]
}
答案 2 :(得分:-2)
为简单起见,请尝试使用此功能:
var vals;
console.log(typeof out)
isobj = typeof(out) === 'object'?true:false
if (Object.values) {
vals = Object.keys(obj).map(function(i) {
if(isobj)
out[i] = obj[i];
})
}else
vals= Object.values(obj)
return vals;
````}