<p>11111111111111111111111</p>
vue-select源码仓库:源码仓库
vue-select介绍、vue-select使用
A native Vue.js select component that provides similar functionality to Select2 without the overhead of jQuery.
AJAX Support
Tagging
List Filtering/Searching
Supports Vuex
Select Single/Multiple Options
Tested with Bootstrap 3/4, Bulma, Foundation
+95% Test Coverage
~33kb minified with CSS
Zero dependencies
vue ~2.0 use vue-select ~2.0
vue ~1.0 use vue-select ~1.0
Install the package.You should installvue-select@1.3.3for use with vue~1.0.
Register the component
import Vue from 'vue'import vSelect from 'vue-select'Vue.component('v-select', vSelect)
You may now use the component in your markup
<v-select v-model="selected" :options="['foo','bar']"></v-select>
Just includevue&vue-select.js- I recommend usingunpkg.
<script src="https://unpkg.com/vue@latest"></script><!-- use the latest release --><script src="https://unpkg.com/vue-select@latest"></script><!-- or point to a specific release --><script src="https://unpkg.com/vue-select@1.3.3"></script>
Then register the component in your javascript:
Vue.component('v-select', VueSelect.VueSelect);
You may now use the component in your markup
<v-select v-model="selected" :options="['foo','bar']"></v-select>
Here’s anexample on JSBin.
The most common use case forvue-selectis to have the chosen value synced with a parent component.vue-selecttakes advantage of thev-modelsyntax to sync values with a parent.
<v-select v-model="selected"></v-select>
new Vue({ data: { selected: null }})
vue-selectaccepts arrays of strings and objects to use as options through theoptionsprop.
<v-select :options="['foo','bar']"></v-select>
When provided an array of objects,vue-selectwill display a single value of the object. By default,vue-selectwill look for a key named ‘label’ on the object to use as display text.
<v-select :options="[{label: 'foo', value: 'Foo'}]"></v-select>