gpt4 book ai didi

twitter-bootstrap - Bootstrap 预输入使大写不敏感?

转载 作者:行者123 更新时间:2023-12-04 07:42:12 31 4
gpt4 key购买 nike

我正在使用此参数在不区分大小写模式下进行 Bootstrap 输入预搜索。

matcher: function(item) {
return true
}

我适用于像输入“e”这样的重音搜索也搜索é,è,ë,ê等......但不适用于大写小写=>输入“g”不寻找“G”......

有没有其他参数?

最佳答案

好的,这是我使用 Paul 的解决方案所做的:

             matcher: function(item) {
if (item.toLowerCase().indexOf(this.query.trim().toLowerCase()) != -1) {
return true;
}
if (item.toUpperCase().indexOf(this.query.trim().toUpperCase()) != -1) {
return true;
}
var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
query = query.replace(/a/ig, '[a\341\301\340\300\342\302\344\304]');
query = query.replace(/e/ig, '[e\351\311\350\310\352\312\353\313]');
query = query.replace(/i/ig, '[i\355\315\354\314\356\316\357\317]');
query = query.replace(/o/ig, '[o\363\323\362\322\364\324\366\326]');
query = query.replace(/u/ig, '[u\372\332\371\331\373\333\374\334]');
query = query.replace(/c/ig, '[c\347\307]');
if(item.toLowerCase().match(query.toLowerCase())){
return true;
}
}

有了这个,你就有了一个真正不敏感的情况。我把主要的特殊字符。您可能需要为匹配添加额外的字符。

关于twitter-bootstrap - Bootstrap 预输入使大写不敏感?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17701738/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com