Reactjs React:Filter函数不区分大小写

Reactjs React:Filter函数不区分大小写,reactjs,filter,case-insensitive,Reactjs,Filter,Case Insensitive,我使用react过滤Json文件。如何进行不区分大小写的搜索 这是我的密码 _handleSearch ({ inputNameValue, inputPriceValue }) { let list = data.filter(hotel => hotel.name.includes(inputNameValue)) } 大小写规范化两个字符串如何,例如,它们都是小写: 请注意,建议在过滤器外部更改输入 _handleSearch ({ inputNameValue, inpu

我使用react过滤Json文件。如何进行不区分大小写的搜索

这是我的密码

_handleSearch ({ inputNameValue, inputPriceValue }) {
  let list = data.filter(hotel => hotel.name.includes(inputNameValue))
  }

大小写规范化两个字符串如何,例如,它们都是小写:
请注意,建议在过滤器外部更改输入

_handleSearch ({ inputNameValue, inputPriceValue }) {
  const lowerCased = inputNameValue.toLowerCase();
  let list = data.filter(hotel => hotel.name.toLowerCase().includes(lowerCased ))
  }
只要执行该案:

_handleSearch ({ inputNameValue, inputPriceValue }) {
    let list = data.filter(hotel => 
    hotel.name.toUpperCase().includes(inputNameValue.toUpperCase()))
 }

hotel.name.toLowerCase().includes(inputNameValue.toLowerCase())
?很好用,谢谢,不过不要每次迭代都这么做。看到我的答案了吗