如何搜索所有参数?

时间:2018-09-30 21:31:54

标签: javascript reactjs redux

我目前仅按名称搜索。此外,还要考虑大小写字母。如何搜索用户的所有参数?而不考虑大小写字母?

我有以下选项:lastNamecompanytitleemailphonestreetcitycountry

dispatch => ({
    onFindPeople: (firstName) => {
        console.log(firstName);
        dispatch({ type: 'FIND_PEOPLE', payload: firstName})
    }
})

我添加了示例代码here

1 个答案:

答案 0 :(得分:1)

尝试

const isMatch = (user, filter) =>
  new RegExp(filter, "i").test(JSON.stringify(user));

state.allPeople.filter(user => isMatch(user, state.filterPeople));