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


https://jsfiddle.net/rgnuaw30/
 

h5: 部分

<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;
     },
    }    
});

转载于:https://www.cnblogs.com/fei33423/p/6974017.html

Logo

前往低代码交流专区

更多推荐