Vue

by jessuni

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-multiselect/2.1.6/vue-multiselect.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<div id="app">
  <multiselect v-bind:options="tags" label="title" track-by="slug" key="slug" multiple searchable />
</div>

<style src="vue-multiselect/dist/vue-multiselect.css"></style>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

li {
  margin: 8px 0;
}

h2 {
  font-weight: bold;
  margin-bottom: 15px;
}

del {
  color: rgba(0, 0, 0, 0.3);
}

JavaScript

const MultiSelect = Vue.component('multiselect', window.VueMultiselect.default)

var app = new Vue({
  el: '#app',
  data: {
    tags: [
      {slug: 'dev', title: 'dev'},
      {slug: 'tech', title: '科技'},
      {slug: 'technology', title: 'tech'},
      {slug: 'libr', title: '人文'}
    ]
  }
})