Filter array of objects that contains string using lodash

后端 未结 3 1019
甜味超标
甜味超标 2021-02-12 13:15

I have a value and i need to return the objects that contains this value in propertie.

var search=\'CPP@\';
var results=_.filter(collection,{VAL:search});
         


        
3条回答
  •  南旧
    南旧 (楼主)
    2021-02-12 13:32

    var results = _.filter(collection,function(obj) {
        return obj.VAL.indexOf(search) !== -1;
    });
    

提交回复
热议问题