select动态绑定vue.js

动态选项,用 v-for 渲染:

 
  1. <select v-model="selected">

  2. <option v-for="option in options" v-bind:value="option.value">

  3. {{ option.text }}

  4. </option>

  5. </select>

  6. <span>Selected: {{ selected }}</span>

 
  1. new Vue({

  2. el: '#demo',

    扫描二维码关注公众号,回复: 2233668 查看本文章
  3. data: {

  4. selected: 'A',

  5. options: [

  6. { text: 'One', value: 'A' },

  7. { text: 'Two', value: 'B' },

  8. { text: 'Three', value: 'C' }

  9. ]

  10. }

  11.  

猜你喜欢

转载自blog.csdn.net/weixin_41722928/article/details/81096464