Could you tell me about the front-end query?

the company needs me to write a query page with static data to show people. My problem now is that there is no problem with a single conditional query. If my first input is correct, the second input error should not be queried. There are multiple conditions, how to achieve this

                let msg = $.trim($(".searchText").val());
                let qwe = $.trim($(".search_one").val());
                let asd = $.trim($(".search_two").val());
                let erType=$.trim($("-sharpyichang option:selected").val());
                let searchTarget = [];
                arr1.map(e=>{

                    if(e.batteryCode == msg | e.battreyV == qwe | e.circleLine == asd |  e.batteryType == erType){
                        searchTarget.push(e)
                    }
                }) 

clipboard.png


and and or learn


recommend a plug-in fusejs


return arr1.filter(e => (e.batteryCode.includes(msg) || e.battreyV.includes(qwe) || e.circleLine.includes(asd) ||  e.batteryType.includes(erType)))

look at your code, it should be exact matching, not fuzzy matching. When there are multiple conditions, it should be and relationship, not or relationship!

  

first determine the requirement, is it a union or a union? For example, if there are conditions A, B, C, your query results should meet these three conditions at the same time? Or as long as one of the conditions is met?
all three are satisfied, that is, A & & B & & C . If one of the conditions is satisfied, check A first, collect if An is satisfied, check whether B is satisfied, meet the same collection, and do not meet B, then check whether C meets C and collect C as well, that is, A | B | C . The sequence of A, B and C is artificially determined.

Menu