我有对象数组
var data = [{type:"A",parentPersonInfo:{id:1,fullname:'john smith'}},{type:"A",parentPersonInfo: {id:1,fullname:'jim smith'}},{type:"B",parentPersonInfo: {id:2,fullname:'jane smith'}}]
我想使用lodash来提取type = A和id = 1
的记录const testId = 1;
_.filter(data,{'type':'A','data.parentPersonInfo.id':1});
但我得到[]
答案 0 :(得分:0)
你能检查下面的代码是否有效吗?
_.filter(data, {type: 'A', parentPersonInfo: {id:1}});