1
我只是在尋找一些關於React.js篩選的建議。我目前通過'employeeName'過濾'peopleList',這工作正常,即時回到我期望的。React.js - 篩選多個indexOf
但我想同時過濾'employeeID',即檢查'employeeName'或'employeeID'是否包含indexOf ..這是可能的還是我需要設置兩個過濾器'employeeName'和'employeeID'?
let people= this.state.peopleList.filter(
(person) => {
return person.record.employeeName.toLowerCase().indexOf(this.state.search.toLowerCase()) !== -1;
// return person.record.employeeID.toLowerCase().indexOf(this.state.search.toLowerCase()) !== -1;
}
);
您是否嘗試過使用''||,*或*操作? 'employeeNameIndexOf!== -1 || employeeIdIndexOf!== -1' –