求教 如何拿出数组对象中code等于46的单独对象? 如图
发布于 4 年前 作者 szhang 7450 次浏览 来自 问答

想把下图中数组对象的code值为46的对象单独拿出来 有没有什么快速好用的方法?

3 回复
const obj = dataMapList.find((ele) => ele.code === 46);

数组api find 很香

let data = [{key:1,code:2},{key:2,code:23},{key:3,code:46},{key:4,code:46}]
data.filter((res)=>{
return res.code === 46
})

回到顶部