1.添加相应的script链接
jquery:
<script type="text/javascript" src="http://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
select2:
css:
js:
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/js/select2.min.js"></script>
2.html页面添加select
<div class="select1">
<select class="mySelect">
<option>西瓜</option>
<option>苹果</option>
<option>香蕉</option>
<option>菠萝</option>
<option>桃子</option>
</select>
</div>
3.在页面添加script
<script>
$(function(){
$('.mySelect').select2({
placeholder: "--请选择--",
allowClear: true
});
})
</script>