[Vuejs]-How to bind v-model to v-select

0👍

This is my working example without v-model same sens, i just appointed value to data

Template

<v-select :onChange="initialPriceControll" :options="price_types"></v-select>`,
js: `export default {
  data() {
    return {
        price_type:'Fixed',
        price_types: [
            'Fixed',
            'Negotiable',
            'Giveaway'
        ],
        show_negotiable_price: false
    }
},
methods: {
    initialPriceControll(e){
        this.price_type = e;
        if (e == 'Negotiable') {
            this.show_negotiable_price = true
        } else {
            this.show_negotiable_price = false
        }
        this.$emit('selectPrice', { 
                display: this.show_negotiable_price,
                price_type: this.price_type
            });
    }
  }
}

0👍

in template:

<v-select
  v-model="theModel"
  v-bind:items="['a', 'b', 'c', 'd']"
  label="theLabel"
 ></v-select>

in script:

data() {
  return {
    theModel: ""
  }
}

0👍

rather than v-model="xxx"
You can use v-model:selected="xxx"
You will get an array

references:

👤Septem

Leave a comment