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;     },    }    });
相關文章
相關標籤/搜索