mirror of
https://github.com/tenrok/vue-select.git
synced 2026-05-17 02:29:37 +03:00
2.7 KiB
2.7 KiB
vue-select
Rather than bringing in jQuery just to use Select2 or Chosen, this Vue.js component provides similar functionality without the extra overhead of jQuery.
Demo
http://sagalbot.github.io/vue-select/
Install / Usage
$ npm install sagalbot/vue-select
<template>
<div id="myApp">
<v-select :value.sync="selected" :options="options"></v-select>
</div>
</template>
<script>
import vSelect from 'vue-select'
export default {
components: {vSelect},
data() {
return {
selected: null,
options: ['foo','bar','baz']
}
}
}
</script>
Parameters
valueRepresents the currently selected value(s). Can benull, an empty string, or[]. Ifmultipleis true, the current value will be represented in an array, otherwise it will be a single string or object, depending on what you've passed foroptions.- twoway: true,
- required: true
optionsAny array of strings or objects to be used as dropdown choices. Supports['foo','bar']&[{label: 'Foo', value: 'foo'}]. When using the[{}]syntax, the objects in the array can have as many properties as you need, as long as the object containsvalueandlabelkeys.- type:
Array - default:
[]
- type:
maxHeightLimit the height of the dropdown menu.- type: String
- default: '400px'
searchableToggle filtering of options.- type: Boolean
- default: true
multipleEquivalent tomultipleattribute on a<select>.- type: Boolean
- default: true
placeholderEquivalent toplaceholderattribute on an<input>.- type: String
- default: ' '
transitionVuetransitionprop applied to the.dropdown-menu.- type: Boolean
- default: true
Todos:
- fix layout issues with multiple selections
- tags overflow outside
.dropdown - search input overflows outside
.dropdown
- tags overflow outside
searchprop should be optionalsimpleprop that disablessearchand keeps a staticplaceholderregardless of current selection (useful for things like icon button dropdowns)- less opinionated styles / only include css necessary to acheive layout (no colors, etc)
- ability to pre-select options when using
[{label: 'Foo', value: 'foo'}]syntax (already works with['foo','bar','baz']syntax - more tests!!
Build Setup for Contributing
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production without minification
npm run build
# build for production with minification
npm run uglify
# lint all *.js and *.vue files
npm run lint
# run unit tests
npm test
For more information see the docs for vueify.