Apr 7, 2017
0
Level 2
Loading "vue-multiselect" with Laravel Mix
I'm using vue-multiselect but I'm having some problems to import it using Laravel Mix.
Right now I only was able to load it directly on the page:
<head>
<style src="https://unpkg.com/[email protected]/dist/vue-multiselect.min.css"></style>
</head>
<body>
<multiselect v-model="option.id" :options="options" :multiple="false" :searchable="true">
</multiselect>
<script src="https://cdn.jsdelivr.net/vue.multiselect/2.0/vue-multiselect.min.js"></script>
<script>
var vm = new Vue({
el: '#content',
components: {
multiselect: VueMultiselect.Multiselect
},
data: {
option.id: 0,
options: ['One', 'Two', 'Three']
}
})
</script>
</body>
That works great!
But how could I use Laravel Mix to import vue-multiselect to my project and load it only on pages that actually use the component?
Vue-Multiselect: https://github.com/monterail/vue-multiselect
ps: I know there are some threads about this issue but I couldn't find a proper answer yet.
Please or to participate in this conversation.