mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 04:23:59 +00:00
51 lines
1.4 KiB
Vue
51 lines
1.4 KiB
Vue
<template>
|
|
<select class="form-control">
|
|
<option disabled></option>
|
|
</select>
|
|
</template>
|
|
<script>
|
|
import PerfectScrollbar from 'perfect-scrollbar';
|
|
export default {
|
|
props: {
|
|
options: {
|
|
type: Array,
|
|
required: true
|
|
},
|
|
value: {
|
|
required: false
|
|
}
|
|
},
|
|
mounted(){
|
|
let vm = this;
|
|
$(this.$el).select2({
|
|
data: this.options,
|
|
minimumResultsForSearch: 6,
|
|
theme: 'bootstrap',
|
|
containerCssClass: 'form-control',
|
|
}).val(this.value).trigger("change").on('change', function(){
|
|
vm.$emit('input', this.value);
|
|
}).on('select2:open', function(){
|
|
$('.select2-results__options').scrollbar().addClass('scrollbar-macosx')
|
|
})
|
|
},
|
|
watch: {
|
|
value: function(value){
|
|
$(this.$el).val(value).trigger('change');
|
|
},
|
|
options: function(options){
|
|
$(this.$el).select2({ data: options });
|
|
this.value ? $(this.$el).val(this.value).trigger('change'):null;
|
|
}
|
|
},
|
|
destroyed: function(){
|
|
$(this.$el).off().select2('destroy')
|
|
}
|
|
}
|
|
</script>
|
|
<style>
|
|
.select2-results__options {
|
|
position: relative;
|
|
max-height: 200px
|
|
}
|
|
</style>
|