select2地址:https://select2.github.io/examples.html
1.引入select2相關文件包括css,js
2.在select 標簽內 class="js-example-basic-single"
3.<script>
$('.js-example-basic-single').select2({
//具體參考select2的api不多舉例
language: 'zh-CN',
minimumInputLength: 1, // 至少輸入n個字符,才去加載數據;若設置為0,則點擊選擇框,不用輸入內容,就去加載數據;默認為0
maximumInputLength: 100, // 限制最大字符
});
</script>
4.個人在使用之后出現了輸入框無法獲取焦點不能輸入解決辦法:
在js里加上 $.fn.modal.Constructor.prototype.enforceFocus = function () { };
