Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vuetify select or combobox bind item

I have a list of objects:

var itens = 
[ {
    name: 'a',
    id: 1
},
{
    name: 'b',
    id: 2
},{
    name: 'c',
    id: 3
}
]

so I show in a select:

<v-select
  :items="itens"
  v-model="selectedItem"
  item-text="name"
  label="Cartório"
  single-line
  ></v-select>

so in my this.selectedItem have the name but I wanna to bind the whole object {id and name} it`s possible?

like image 340
Fabio Ebner Avatar asked Jul 03 '18 15:07

Fabio Ebner


1 Answers

Yes it's possible.

You have to use return-object props of v-select

Like that :

<v-select
  :items="items"
  v-model="selectedItem"
  item-text="name"
  label="Cartório"
  single-line
  return-object
  />

CodePen

Vuetify Doc about return-obejct in v-select

like image 144
Toodoo Avatar answered Oct 20 '22 10:10

Toodoo