LoginSignup
5
4

More than 5 years have passed since last update.

v-modelに複数のselectboxをバインドする

Posted at

やりたいこと

「複数のアイテムがそれぞれselectboxを持つUI」をv-modelで表現する。

id:1のselectbox
<select name="" v-model="?">
   <option value="a">A</option>
   <option value="b">B</option>
</select>

id:2のselectbox
...

id:3のselectbox
...

方法

CodePenを見たほうが話が早いと思う。
v-modelを{ アイテムのid: 選択した値 }という形式のobjectにしてそれを素直に書いた感じ。

See the Pen vue v-model multi-select by seihmd (@seihmd) on CodePen.

5
4
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
5
4