Vuetify: 1.0.14
Vue: 2.5.16
Browsers: Safari 11.1
OS: Mac OS 10.13.4
Corresponding option should be selected.
Nothing is selected.
What are you trying to do is the following:
const obj1 = {hi:'hello'};
const obj2 = {hi:'hello'};
console.log(obj1 === obj2) //false
https://vuetifyjs.com/en/components/selects#example-custom-text-and-value
if you want to compare the object properties pass them as a parameter
list: [
{
id: "1",
name: "Foo"
},
{
id: "2",
name: "Bar"
}
]
<v-select
:items="items"
v-model="select"
item-text="name"
item-value="id"
return-object
></v-select>
Your example would work only with two properties, right? If I need each option to be a 3-property object — I can't do that because of JS behavior?
you will need only 2 things: value and text
value: id.userCode
text: name.lastName
{
id: {
userCode: 1,
something: 3
},
name: {
firstName: 'foo',
lastName: 'bar'
}
}
I need to be able to select between complex object values by one input field. So I need v-model to actually store this complex value to send it to the api later.
You need to tell the select what it's supposed to key on with item-value and item-text. The value must be a primitive as v-select uses a strict equality check (===).
Most helpful comment
What are you trying to do is the following:
https://vuetifyjs.com/en/components/selects#example-custom-text-and-value
if you want to compare the object properties pass them as a parameter