<html>
<head>
<title>下拉框附帶搜索框</title>
<link href="${rc.contextPath}/statics/js/jquery-select2/3.4/select2.min.css" rel="stylesheet">
<script src="${rc.contextPath}/statics/js/jquery-select2/3.4/select2.min.js" type="text/javascript"></script>
</head>
<body>
<form>
<div>項目名稱</div>
<div>
<select id="names" class="projSelect" v-model="...">
<option value="">請選擇項目名稱</option>
<option v-for="(item,i) in projList" :value="item.id">{{item.name}}</option>
</select>
</div>
</div>
<script>
$(function () {
$('.projSelect').select2();
})
</script>
</form>
</body>
</html>
主要就是紅色標注的代碼,當然相對路徑不一樣,直接復制需要修改路徑。
jquery-select2.zip
