Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get an object rather than a single value when clicking on a v-select item?

My v-select's data is an array of objects. For each item, the value is one property and the text for that item is a different property. However I really need to retrieve both, not just the value.

So I guess I need to retrieve the object. Is it possible?

V-select code:

<v-select
  :items="projects"
  v-model="project"
  item-text="projectName"
  item-value="projectId"
  solo
></v-select>

This is how the array of items is populated (in mounted hook):

querySnapshot.forEach((doc) => {
  let data = {
    'projectId': doc.id,
    'projectName': doc.data().name,
    'clientId': doc.data().clientId
  }
  this.projects.push(data);
});
like image 634
drake035 Avatar asked Dec 02 '18 17:12

drake035


1 Answers

Add return-object prop:

<v-select return-object>

See docs:

https://vuetifyjs.com/en/components/selects#example-custom-text-and-value

like image 146
Traxo Avatar answered Oct 14 '22 22:10

Traxo