LoginSignup
0
0

More than 3 years have passed since last update.

v-forを使ってselect optionを生成

Posted at
<div id="app">
  <select name="user" v-model="selected">
    <option disabled value="">選択して下さい</option>
    <option v-for="user in users" v-bind:value="user.name" v-bind:key="user.id">
      {{user.name}}
    </option>
  </select>
</div>
new Vue({
  el: '#app',
  data: {
    users: [
      {id:1, name:'佐々木'},
      {id:2, name:'鈴木'},
      {id:3, name:'高木'}
    ],
    selected: ''
  }
})
0
0
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
0