アンダースコア官网:http://underscorejs.org/
参考文档:http://www.css88.com/doc/underscore/
页面代码:
@{viewbag.title = "index";} <script src = "scripts/bootstrap-typeahead.js"> </script> <scrip = "scripts/nouderscore-min.js"> </script> <div>简单使用
<div style = "マージン:10px 50px"> <ラベル= "product_search">製品検索:</label> <入力id = "product_search" type = "text" data-provide = "typeahead" data-source = '["data1"、 "data2"、 "data3"'/> </div>
使用脚本填充数据
<div style = "マージン:10px 50px"> <ラベル= "product_search">製品検索:</label> <入力id = "product_search_js" type = "text" data-provide = "typeahead"> div> <script = "text/javascript"> $(document(document).teread($){$ .fn.typeaheadorconstortor (){var that = this; setimeout(function(){that.hide()}、250);}; $( '#product_search_js')。typeahead({source:function(query、process){return ["js数据1"、 "js数据2"、 "js数据3"] "<==";}、updater:function(item){console.log( "'" + item + "' selected");支持ajax获取数据
<div style = "マージン:10px 50px"> <ラベル= "product_search"> product search:</label> <input id = "product_search_ajax" type = "text" data-provide = "typeahead"> div> <script = "text/javascript"> $( '#product_ajax')。 {query:query}; $。post( '@url.action( "ajaxservice")'、parameter、function(data){process(data);});}}); </script>使用对象数据
<div style = "マージン:10px 50px"> <ラベル= "product_search">製品検索:</label> <入力id = "product_search_object" type = "text" data-provide = "typeahead"> div> <script = "text/javascript"> $(function(){var products(){id:0:0、 1、name: "object2"、rise:134.99}、{id:2、name: "object3"、rice:49.95}]; $( '#product_search_object')。 {return "==>" + item + "<==";}、updater:function(item){console.log( "'" + item + "' selected。"); return item;}});}); </scrip> </div>控制器
public ActionResult index(){return View();} public ActionResult ajaxservice(){string query = ""; if(!string.isnullorwhiteSpace(request ["query"]))query = request ["query"]。效果图展示如下:
下面继续给大家介绍ブートストラップ
以上所述是小编给大家介绍的ブートストラップ学习系列之使用ブートストラップtypeahead组件实现百度下拉效果、希望对大家有所帮助、如果大家有任何疑问请给我留言、小编会及时回复大家的。在此也非常感谢大家对武林网网站的支持!