ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ $('.deliveryAddress select').select2({ matcher: (params, data)=>{ // If there are no search terms, return all of the data if ($.trim(params.term) === '') { return data; } // Do not display the item if there is no 'text' property if (typeof data.text === 'undefined') { return null; } // `params.term` should be the term that is used for searching // `data.text` is the text that is displayed for the data object let keywords = params.term.split(' '); let matchCounter = 0; $.each(keywords, function(index, keyword) { let text = data.text.toLowerCase(); text.indexOf(keyword.toLowerCase()) > -1 && matchCounter++; }); if (matchCounter == keywords.length) { // This includes matching the `children` how you want in nested data sets return $.extend({}, data, true); } // Return `null` if the term should not be displayed return null; } }); ~~~