首页 > 代码库 > vue selected联动查询实例2

vue selected联动查询实例2

<body id="app">
    <select v-model="selected" id="text"> 
        <option v-for="option in options"> {{option.text}} </option>
    </select> 
    <br />
    <br />
    <br />
    <select v-model="list"> 
        <option v-for="v in list">{{v.a}}-{{v.b}} </option>
    </select> 
  </body>

new Vue({
    el: ‘#app‘,
    data: {
       selected:"A",
         options: Array
    },
    ready: function () {
      let option= [
         { text: ‘One‘, value: [{a:1,b:2},{a:2,b:3},{a:3,b:4}] },
         { text: ‘Two‘, value: [{a:11,b:22},{a:22,b:33},{a:33,b:44}] }, 
         { text: ‘Three‘, value: [{a:111,b:222},{a:222,b:333},{a:333,b:444}] } 
       ];
       this.$set("options",option);
         console.log(this.options);
    },
    computed: {
        list: function () {
            for(var i in this.options){
                // console.log(this.options[i].text)
                if(this.options[i].text == this.selected){
                    console.log(this.options[i].value)
                    return this.options[i].value
                }
            }
        }
    }
  })

http://www.cnblogs.com/jasonwang2y60/p/6404352.html 

vue selected联动查询实例2