Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
搜索元素并在reactjs中返回与其对应的对象_Reactjs - Fatal编程技术网

搜索元素并在reactjs中返回与其对应的对象

搜索元素并在reactjs中返回与其对应的对象,reactjs,Reactjs,我的应用程序按名称在对象数组中搜索。现在,当我搜索时,我得到了与名称对应的第一个对象,但当我尝试写第二个名称时,问题出现了,我什么也没有得到,因为当我搜索时,我只搜索一个单词: const search=selectedItems=>{ 让arrayOfMatchedObjects=elements.filter(对象=>{ 返回JSON.stringify(对象) .toString() .toLowerCase() 。包括(选择编辑项); }); console.log(ArrayOfMa

我的应用程序按名称在对象数组中搜索。现在,当我搜索时,我得到了与名称对应的第一个对象,但当我尝试写第二个名称时,问题出现了,我什么也没有得到,因为当我搜索时,我只搜索一个单词:

const search=selectedItems=>{
让arrayOfMatchedObjects=elements.filter(对象=>{
返回JSON.stringify(对象)
.toString()
.toLowerCase()
。包括(选择编辑项);
});
console.log(ArrayOfMatchedObject);
};

搜索(selectedItems.join(“,”.toLowerCase())你能更新沙箱吗?它现在不工作。@Pavan,检查pleaseStill不工作。elements.js文件是empty@Pavan,解决了,现在可以了?@Pavan,我不知道为什么我不能保存文件。我在问题中插入了数组。你能更新沙盒吗?它现在不工作。@Pavan,检查pleaseStill不工作。elements.js文件是empty@Pavan,解决了,现在可以了?@Pavan,我不知道为什么我不能保存文件。我在问题中插入了数组