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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-04-13 11:00:00 +0000
Seen: 10 times
Last updated: Nov 23 '21
How can TextField(value:format:prompt:) be set back to the initial prompt text?
How can wrapping be turned off in a textarea?
How can I display only the name and hide the button and text input box?
How can I load a text file in gensim?
How can I indent numerous lines of the HTML tag <p>?
How can I change the name of a subfolder within multiple folders by replacing a portion of the text?
How to arrange columns in a Flutter datatable?
How can I use html-React to substitute specific text within a contentEditable div?
How can the text size of the plot be enlarged using ggcuminc?