[Vuejs]-How to import Vue multiselect in plain js file without CLI

1👍

Try like following snippet , with components: { Multiselect: window.VueMultiselect.default }:

var app = new Vue({
  el: '#app',
  components: { Multiselect: window.VueMultiselect.default },
  data () {
    return {
      value: [],
      options: [
         {"name": "aaa", "id": "1",},
         {"name": "bbb", "id": "2",},
         {"name": "ccc", "id": "3",}
       ]
    }
  }
})
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-multiselect@2.1.0"></script>
<link rel="stylesheet" href="https://unpkg.com/vue-multiselect@2.1.0/dist/vue-multiselect.min.css">
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
<div id="app">
  <multiselect
    v-model="value"
    placeholder="chose"
    label="name" 
    track-by="id"
    :options="options"
    :multiple="true"
    :taggable="true"
  ></multiselect>
<pre>{{ value  }}</pre>
</div>

Leave a comment