首先從https://github.com/harvesthq/chosen/releases 下載下傳最新的chosen npm插件,用npm安裝
在項目中添加一個檔案 http://blog.csdn.net/qq_27093465/article/details/49074471
内容如下
import $ from 'jquery'
window.$ = $
window.jQuery = $
export default $
然後把chosen的css和圖檔放到
需要使用chosen的vue元件中引入此檔案
然後就可以愉快的在vue中調用chosen了
需要注意的是chosen并不支援v-model,是以做雙向綁定需要
html部分
<select class="chosen-select" v-model="要改的變量">
<option v-for="opt in infolist" :value="opt.value">{{opt.label}}</option>
</select>
js部分
var self = this
$('.chosen-select').chosen({disable_search: true}).change(function () { self.要改的變量 = $('.chosen-select').val() })
chosen的基本調用請查考大師兄的文章
http://blog.csdn.net/qq_27093465/article/details/49074471