zoukankan      html  css  js  c++  java
  • vuejs 中 select 动态填充数据,后台的数据

           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;
         },
        }    
    });
  • 相关阅读:
    Codeforces 937D
    Codeforces 458C
    Codeforces 934D
    Codeforces 934C
    Codeforces 36B
    Codeforces 374C
    Codeforces 374D
    编译优化
    Codeforces E
    Codeforces 920G
  • 原文地址:https://www.cnblogs.com/fei33423/p/6974017.html
Copyright © 2011-2022 走看看