企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] > [手册](https://bootstrap-autocomplete.readthedocs.io/en/latest/) ## 安装 ``` 经过测试,这个版本支持 v3 的boostcss <script src="https://raw.githubusercontent.com/xcash/bootstrap-autocomplete/v2.3.0/dist/latest/bootstrap-autocomplete.js"></script> npm install bootstrap-autocomplete ``` ## 场景 ## hello world js 用法 ``` <input class="form-control basicAutoComplete" type="text" autocomplete="off"> $('.basicAutoComplete').autoComplete({ resolverSettings: { url: 'testdata/test-list.json' } }); ``` 使用data ``` <input class="form-control basicAutoComplete" type="text" data-url="myurl" autocomplete="off"> $('.basicAutoComplete').autoComplete(); ``` ### 复杂设置 ``` $('#send_id').autocomplete({ source:function(query,process){ var matchCount = this.options.items; $.getJSON(url,{"key":query,"top":matchCount},function(respData){ return process(respData); }); }, formatItem:function(item){ return item["user_name"]; }, setValue:function(item){ return {'data-value':item["user_name"],'real-value':item["user_id"] + sp_item + item["user_name"]}; }, select:function(dataVal,realVal){ var arr=realVal.split(sp_item); selectUserSearch(arr[0],arr[1]); } }); ```