Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
921 views
in Technique[技术] by (71.8m points)

lodash 有没有在复杂对象中查找指定键值对的方法?

举个例子子:
`

data = [
    {
        id:1,
        name: 'a',
        group: [
            {
                label: 111
                id:222
            },
            {
            label: 111
            id:3333
            },
            {
                ids:[
                    {
                        id:'这是要查找的深层目标'
                    }
                ]
            }
        ]
    }
]

`

就类似与上面这种非常非常复杂的结构,有没有直接点的方法比如说:

_.(data, id => id == '这是要查找的深层目标') 然后直接返回如下:

{id: '这是要查找的深层目标'}.

如果没有,有什么思路给他加一个,要不然 多次遍历太复杂了,新手求教大佬


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...