I have been attempting to implement the Vue.js multiselect component from the following link:
However, I am encountering an issue where instead of the expected multiselect dropdown, the output is not as desired and looks like this:
https://i.sstatic.net/if0d7.png
Here is the code I am using:
HTML:
<div id="app">
<button @click="toggle">open and close later
</button>
<pre>{{ isOpen }}</pre>
<multiselect
ref="multiselect"
v-model="value"
:options="options"
:multiple="true"
track-by="library"
:custom-label="customLabel"
@close="isOpen = false"
@open="isOpen = true"
>
</multiselect>
</div>
Libraries used (included in code):
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.18/vue.min.js"></script>
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="067073632b6b736a726f75636a636572463428372836">[email protected]</a>"></script>
<link rel="stylesheet" href="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="275152420a4a524b534e54424b4"b</a>/dist/vue-multiselect.min.css">
Script used (placed at the bottom of the page):
<script>
new Vue({
components: {
Multiselect: window.VueMultiselect.default
},
data: {
isOpen: false,
value: { language: 'JavaScript', library: 'Vue-Multiselect' },
options: [
{ language: 'JavaScript', library: 'Vue.js' },
{ language: 'JavaScript', library: 'Vue-Multiselect' },
{ language: 'JavaScript', library: 'Vuelidate' }
]
},
methods: {
customLabel (option) {
return `${option.library} - ${option.language}`
},
toggle () {
this.$refs.multiselect.$el.focus()
setTimeout(() => {
this.$refs.multiselect.$refs.search.blur()
}, 400)
}
}
}).$mount('#app')
</script>