Vuetify 3: how to get selected item from v-select?

229 views Asked by At

In vuetify 2 I created v-selects in a loop based on values of an array. On each v-select I added the ref keyword. That way I could loop all the selects and pick out the selected items in each v-select like so:

 <v-select :model-value="questions.find(x => x.selected==true" :items="getSortedAnswers(question.answers[0].answer)" ref="answer_selects"></v-select>

  let selects = this.$refs["answer_selects"];      
  selects.forEach((item) => {

    if (item.selectedItems && item.selectedItems.length > 0) {
      let questionId = item.selectedItems[0].questionID;
      let answerId = item.selectedItems[0].id;
    }
  });

So, in vuetify 2 every item in the "selects" array had a "selectedItems"-property from where I could access the currently selected item. This does not seem to exist in vuetify 3. How can I now get the selected item from each v-select?

(one difference I noticed is also that in vuetify 3 I now use :model-value instead of :value inside the v-select. I guess they've made some other changes also..

0

There are 0 answers