0
2

More than 3 years have passed since last update.

Vue Selectの簡単な使い方まとめ

Last updated at Posted at 2021-05-23

Vue.jsでプルダウン形式のコントロールを実装できるVue Selectを使う際のメモ。

公式ドキュメント

使い方

HTML


<div id="app">
 <v-select v-bind:options="options" v-model="selected" :loading="options.length <= 0"></v-select>
 <p>値:{{selected}}</p>
</div>

JavaScript


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

new Vue({
  el: '#app',
  data: {
    options: ["選択肢1","選択肢2"],
    selected: '',
  }
})

v-selectにバインドされたoptions配列の中身がプルダウン形式で選択できる。
選択した値はselectedにアクセスすることで参照できる。
loadingオプションを指定することで、選択肢をバックグラウンドで取得している間などにローディングマークを表示できる。

CodePenサンプル(CSSは公式テンプレートのまま)

See the Pen Vue Select Sample by shoito66 (@shoito66) on CodePen.

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2