Vue vue-select label

by kabanoki

HTML

<div id="app">
  <v-select v-bind:options="options" v-model="selected">
    <template #option="list">
      <h3 style="margin: 0">{{ list.label }}</h3>
      <em>[code: {{ list.code }}]</em>
    </template>
  </v-select>
    <p>
  値:{{selected}}<br>
  値(code):{{selected.code}}
  </p>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>
<script src="https://unpkg.com/[email protected]"></script> 
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/vue-select.css">

CSS

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

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

p{
  padding:10px;
}

Vue

const VueSelect = window.VueSelect;

Vue.component('v-select', VueSelect.VueSelect)

new Vue({
  el: '#app',
  data: {
    selected: '',
    options: [
      {label: '中国語', code: 'ch'},
      {label: '日本語', code: 'ja'},
      {label: '英語', code: 'en'},
      {label: '韓国語', code: 'kr'},
    ]
  }
})