// 需求:根据Id取出数组中指定的对象
  let arr =  [
      { id: 1, rotationAngle: 330, target: '目标1' },
      { id: 2, rotationAngle: 270, target: '目标2' },
      { id: 3, rotationAngle: 210, target: '目标三' },
  ]

  function getTargetObjById (id) {
    return arr.find(item => item.id === id)
  }
  
  console.log(getTargetObjById(2)) // { id: 2, rotationAngle: 270, target: '目标2' },

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-12-29
  • 2021-12-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
相关资源
相似解决方案