有这么一个数组 [{a,'123',b:'345',c:'456',d:'t12'},{a,'234',b:'345',c:'thf2',d:'t12'}], 现在希望能够通过逗号分隔搜索值的输入方式,从数组中过滤出模糊匹配的数组元素...源码:
function filterByInput(array, input) {
// 解析输入,如果输入有逗号,就将其分割为多个子字符串,然后分别进行过滤
const searchValues...array.filter(item => {
for (let searchValue of searchValues) {
// 对数组中的每个元素进行过滤...];
const input = '123,thf2'; // 你可以修改这个输入值进行测试
console.log(filterByInput(array, input)); // 输出过滤后的数组