To make the Vuetify Combobox return the id instead of the value, you can use the item-value
prop. This prop specifies which object property to use as the value of the selected item. By default, it uses the "value"
property of the object.
Here's an example of how to use the item-value
prop to return the id
property of each item:
<template>
<v-combobox
v-model="selectedItem"
:items="items"
item-text="text"
item-value="id"
/>
</template>
<script>
export default {
data() {
return {
selectedItem: null,
items: [
{ id: 1, text: 'Item 1' },
{ id: 2, text: 'Item 2' },
{ id: 3, text: 'Item 3' },
],
}
},
}
</script>
In this example, the items
array contains objects with id
and text
properties. The item-value
prop is set to "id"
, which means that the selectedItem
property will contain the id
of the selected item, rather than its text
value.
Asked: 2021-04-13 11:00:00 +0000
Seen: 12 times
Last updated: Nov 23 '21