lodash 判断一个数据是否包含另一个数组

if (!_.isEmpty(_.intersection(v.ids, value))) {
this.groupListExtData.push(v.names);
}
 
先使用_.intersection,判断两个数组是否有交集,有的话,就属于包含关系,否则就没有包含关系
_.isEmpty用来判断交集是否为空
 

猜你喜欢

转载自www.cnblogs.com/chendaoyin/p/9167938.html