📌  相关文章
📜  如果 id 存在则反应数组不添加元素 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:49.677000             🧑  作者: Mango

代码示例1
addPerson = (person) => {
    let filteredPerson = this.state.likes.filter(like => like.name !== person.name);
    this.setState({
      likes: [...filteredPerson, person]
    })        
  }