为什么这是有效的:
return elements.map((e)=> {return Object.assign({}, e, {selected:true})});
但这不会:
return elements.map((e)=> {...e, {selected: true}});
?
ES6 / Babel / React 的新手,请怜悯。
更新:移至此后(如建议):
return elements.map(e => ({...e, selected: true }));
尽管传播在项目的其他地方起作用:
return [
...state,
element(undefined, action)
]