data = [
{id:1,name:'张三'},
{id:2,name:'李四'},
{id:3,name:'王五'}
]
let item = 2
// 使用find方法根据id查询对应对象 let a = data.find((ele)=>{ return ele.id == item }); console.log(a)
data = [
{id:1,name:'张三'},
{id:2,name:'李四'},
{id:3,name:'王五'}
]
let item = 2
// 使用find方法根据id查询对应对象 let a = data.find((ele)=>{ return ele.id == item }); console.log(a)