vuejs 中 select 动态填充数据,后台的数据

       selected:"A" 对
       selected:A 错.  变量不用引号. 内容必定要引号.


https://jsfiddle.net/rgnuaw30/
 

h5: 部分javascript

<script src="https://cdn.jsdelivr.net/vue/latest/vue.js"></script>

<div id="app">
  <select v-model="selected">
  <option v-for="option in options" v-bind:value="option.value">
    {{ option.text }}
  </option>
</select>
<span>Selected: {{ selected }}</span>
<br>
</div>
 
 javascript 部分:
 
var vm=new Vue({    el: '#app',    data: {       selected:"A"    },    computed:{     options:function(){           var array= [            { text: 'One', value: 'A' },            { text: 'Two', value: 'B' },            { text: 'Three', value: 'C' }          ];       return array;     },    }    });
相关文章
相关标签/搜索