Home > database >  Get data from v-select field
Get data from v-select field

Time:06-23

I'm getting stuck on getting the data from my v-select input. Within console.log whenever I type it's just repeating an empty string with no data being sent.

Input

  <v-select name="user" v-model="selectedUser"  @select="testingMethod" @input="changeUser" label="user" :options="videos">
  </v-select>

Data

  data() {
    return {
      selectedUser:'',
    }

Method

 methods: {

    changeUser: function() {
      console.log(this.selectedUser)
    }
}

CodePudding user response:

@input event is triggered when you select an item not when you type, you could use @search event :

  <v-select name="user" v-model="selectedUser"  @select="testingMethod" @search="changeUser" label="user" :options="videos">
  </v-select>

CodePudding user response:

Try using @change instead of @input. Just a guess as I am not familiar with Vuetify controls which I am assuming v-select comes from.

Also, use :items instead of :options.

https://vuetifyjs.com/en/components/selects/#usage

<v-select name="user" v-model="selectedUser"  @select="testingMethod" @change="changeUser" label="user" :items="videos">
  </v-select>
  • Related