React:过滤函数不区分大小写
React: Filter function case insensitive
我正在对 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()))
}
我正在对 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()))
}