I have a v-autocomplete
and I want to have multiple chips, that's easy by adding the multiple
prop.
But I want to have multiple chips with the same name and value. I haven't been able to find a solution for that.
Here is my code:
<v-autocomplete
filled
chips
multiple
v-model="selectedRooms"
:items="roomChoices"
hide-no-data
hide-selected
label="Select Rooms"
placeholder="Select from the available choices"
prepend-icon="mdi-bed"
clearable
deletable-chips
>
</v-autocomplete>
data: () => ({
property_name: null,
dialog_active: false,
roomChoices: ['bedroom', 'kitchen', 'bathroom', 'living-room'],
values: [],
}),
It is not possible to select the same value items in Vuetify's Autocomplete because if we can select the same value items twice then there is no way for Vuetify to detect which item has been selected and which item to remove when requested.
Now, This is where the requirement comes in that "Each item should have a unique identifier for Vuetify to know which item has been selected/removed."
However, if you want to select the same items with the same property twice (which makes less sense though), you can create that item twice in your data array but give each same item a unique identifier (let's say an id). Also, use the
return-object
prop to know which item among the same items has been selected.Below is the demo where I created an array of objects data structure where some items have the same title but a unique id and I also used a
return object
prop to store the selected item's whole object instead of the title only.