有一個時間串列,大寫。如果輸入文本為小寫,我該如何找到它們?
例如:巴塞羅那,當輸入“bar”時,找到它。嘗試使用 .lowercase() 但不起作用
onSearch(text){
if(text){
const filter_data=this.old_locations.filter((element) => element.title.includes(text));
this.locations=filter_data;
}else{
this.locations=this.old_locations;
}
}
uj5u.com熱心網友回復:
這個怎么樣
this.locations = text ? this.old_locations
.filter(element => element.title.toLowerCase().includes(text.toLowerCase())) :
this.old_locations;
通過先小寫文本來節省一些周期
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/354098.html
標籤:javascript 离子框架 离子4
