React setState更新数组中的某个元素Element item

  1. var items = this.state.items;  
  2. items[i].status = 'doing';  
  3. this.setState({  
  4.       items: items  
  5. });  

//this.state.useLists[index].status === '10'?
  let items = this.state.useLists;
  items[index] === '10' ? items[index] = '20' : items[index] = '10';
  this.setState({
  useLists:items
});

posted @ 2017-09-18 11:31  winyh  阅读(6794)  评论(0编辑  收藏  举报