【发布时间】:2021-02-08 18:15:35
【问题描述】:
我有
const abc = {
main: {
primary: 'initialPrimary',
},
buttons: {
text: 'initialText',
},
}
const updateAbc = (node, key, value) => {
return {updated abc}
}
所以,如果我调用updateAbc('main','primary','updatedPrimary'),它应该返回更新后的 abc 对象
{
main: {
primary: 'updatedPrimary',
},
buttons: {
text: 'initialText',
},
}
或者当调用updateAbc('buttons','text','updatedText')时,它应该返回更新后的带有值的abc对象
{
main: {
primary: 'initialPrimary',
},
buttons: {
text: 'updatedText',
},
}
它应该只更新传递的值。在 es6 中如何实现?
【问题讨论】:
标签: javascript reactjs ecmascript-6