vue寫select框

<select v-model="selected" @click="selectPamas">
             <option v-for="option in options" v-bind:value="option.value">
               {{ option.text }}
             </option>
</select>this

 

<script>
    export default {
        data() {
            return {
                  selected: 'A',
                    options: [
                      { text: 'One', value: 'A' },
                      { text: 'Two', value: 'B' },
                      { text: 'Three', value: 'C' }
                    ]
                    }
  
                  },
          methods:{
                      selectPamas(){
                          console.log(this.selected);
                      }
                  }ip

    }io

</script>console

相關文章
相關標籤/搜索