react中 数组中对象修改值
作者:互联网
updata=(obj)=>{
let {id,done} = obj
let {todos} = this.state
let newTodos = todos.map(item=>{
if(item.id === id ){
return {...item,done}
}else{
return item
}
})
this.setState({
todos:newTodos
})
console.log(this.state)
}
标签:obj,item,react,修改,let,数组,return,id,todos 来源: https://blog.csdn.net/weixin_44286765/article/details/122001091