使用插件:https://github.com/snapappointments/bootstrap-select
问题:bootstrap-select插件在webpack中点击无响应
解决方案:
1、在入口文件中按顺序引入css和js
import 'bootstrap/dist/css/bootstrap.min.css'
import "bootstrap-select/dist/css/bootstrap-select.min.css";
import $ from 'jquery';
import 'bootstrap/dist/js/bootstrap.min.js';
import "bootstrap-select/dist/js/bootstrap-select.min.js";
2、资源不能重复引入(如bootstrap.js)
https://github.com/snapappointments/bootstrap-select/issues/2397
3、通过js添加的select元素,需延迟调用初始化方法重新初始化
this.inputElement=$("<div>");
this.select=$("<select class='selectpicker' multiple>");
this.inputElement.append(this.select);setTimeout(() => {$('.selectpicker').selectpicker();
}, 300);