Javascript Twitter typeahead本地数据集不工作

Javascript Twitter typeahead本地数据集不工作,javascript,twitter-bootstrap,Javascript,Twitter Bootstrap,我正试图通过使用post at实现Twitter typeahead 我已从下载了typeahead.js 0.11.1 我的HTML是 <body> <input id="test" type="text" class="typeahead tt-input" autocomplete="off" spellcheck="false"> </body> 但是,提前输入功能不起作用。我在输入时在文本框中看不到任何提示。此外,浏览器控制台中没有登录 有

我正试图通过使用post at实现Twitter typeahead

我已从下载了typeahead.js 0.11.1

我的HTML是

<body>
    <input id="test" type="text" class="typeahead tt-input" autocomplete="off" spellcheck="false">
</body>
但是,提前输入功能不起作用。我在输入时在文本框中看不到任何提示。此外,浏览器控制台中没有登录

有人能帮忙吗? 提前感谢。

var numbers = new Bloodhound({
    datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.num); },
    queryTokenizer: Bloodhound.tokenizers.whitespace,
local: [
{ num: 'one' },
{ num: 'two' },
{ num: 'three' },
{ num: 'four' },
{ num: 'five' },
{ num: 'six' },
{ num: 'seven' },
{ num: 'eight' },
{ num: 'nine' },
{ num: 'ten' }
]
});

// initialize the bloodhound suggestion engine
numbers.initialize();

// instantiate the typeahead UI
$('input').typeahead(null, {
displayKey: 'num',
source: numbers.ttAdapter()
});

您如何在页面中包含
typeahead
?您不需要
。typeahead
如果您是通过id
$(“#测试”)
进行选择,我将包含typeahead,如下所示:我已经尝试了$(“#测试”)。typeahead,但没有成功的机会。谢谢您的回复@shri。我认为js导入有问题?我的顺序是,是否有其他js覆盖事件的可能性?这只猎犬的东西很好:)。不知道是什么。看来我现在需要读一下。非常感谢。
var numbers = new Bloodhound({
    datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.num); },
    queryTokenizer: Bloodhound.tokenizers.whitespace,
local: [
{ num: 'one' },
{ num: 'two' },
{ num: 'three' },
{ num: 'four' },
{ num: 'five' },
{ num: 'six' },
{ num: 'seven' },
{ num: 'eight' },
{ num: 'nine' },
{ num: 'ten' }
]
});

// initialize the bloodhound suggestion engine
numbers.initialize();

// instantiate the typeahead UI
$('input').typeahead(null, {
displayKey: 'num',
source: numbers.ttAdapter()
});