第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Typeahead.js 不顯示建議

Typeahead.js 不顯示建議

胡子哥哥 2023-03-10 13:30:36
我正在嘗試為輸入框提前輸入。為此,我正在使用typeahead.js 。我正在使用相同的代碼來學習此功能。雖然我沒有收到任何錯誤,但它沒有顯示建議。我還包含了所有需要的腳本,如下所示:<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.min.js"></script>  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  <script src="the-basics.js"></script>Html 如下:<div class="container"><div id="the-basics">  <input class="typeahead" type="text" placeholder="States of USA"></div>  </div>js如下:var substringMatcher = function(strs) {console.log('strs', strs);return function findMatches(q, cb) {  console.log('q', q);  var matches, substringRegex;  // an array that will be populated with substring matches  matches = [];  console.log('matches', matches);  // regex used to determine if a string contains the substring `q`  substrRegex = new RegExp(q, 'i');  // iterate through the pool of strings and for any string that  // contains the substring `q`, add it to the `matches` array  $.each(strs, function(i, str) {    if (substrRegex.test(str)) {      matches.push(str);    }  });    console.log('matches', matches);  cb(matches);};};    var states = ['Alabama', 'Alaska', 'Arizona', 'California',    'Colorado', 'Connecticut', 'Delaware', 'Florida'  ];    $('#the-basics .typeahead').typeahead({    hint: true,    highlight: true,    minLength: 1  },  {    name: 'states',    source: substringMatcher(states)  });請幫我解決這個問題。
查看完整描述

1 回答

?
Smart貓小萌

TA貢獻1911條經(jīng)驗 獲得超7個贊

const states = [

  "Alabama",

  "Alaska",

  "Arizona",

  "California",

  "Colorado",

  "Connecticut",

  "Delaware",

  "Florida"

];


$("#the-basics .typeahead").typeahead({

  hint: true,

  highlight: true,

  minLength: 1,

  name: "states",

  source: states

});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.min.js"></script>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />



<div class="container">

  <div id="the-basics">

    <input class="typeahead" type="text" placeholder="States of USA" autocomplete="off">

  </div>

</div>


查看完整回答
反對 回復 2023-03-10
  • 1 回答
  • 0 關(guān)注
  • 107 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號