0
当我去链接 http://127.0.0.1:8000/hashtag.json?q=g 检查JSON,我得到这样的列表: [{ “Q”: “#django”},{ “Q”:“#在我输入字母g时,我在下拉列表中只输入“django”显示为一个建议Typeahead.js显示出较低的结果
当我键入:去 我得到2个结果在我的JSON清单,并建议2在下拉:Django和谷歌
瓦可能是问题?
我不认为我的代码中可能存在问题。但我仍然决定在这里发布。
var hashTags = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('q'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: '/hashtag.json?q=%QUERY',
remote: {
url: '/hashtag.json?q=%QUERY',
wildcard: '%QUERY'
}
});
$('.search-tag-query').typeahead({
hint:true,
highlight: true,
autoselect:true,
minLength:1,
limit: 10,
},
{
name: 'hashTags',
displayKey: 'q',
source: hashTags.ttAdapter(),
});