After providing a custom function to value-comparator
, I have realized that it's a way to decide which item should appear after selection is made and the dropdown is closed.
Does this property serve any other purpose, i.e., v-model
or dim selected item
?
value-comparator
controls which values are currently shown as selected in v-select
and v-autocomplete
.
By default, it uses a strict comparison:
valueComparator: (a, b) => Math.round(a) === Math.round(b)
It serves a purpose in v-model
in that it is used to determine whether the value passed to v-model
is being correctly detected as "selected". For example, if the list of items
passed to v-select
uses integer ids as values, and the data value initially passed to v-model
is a string, v-select
will show that no value was selected. You can either cast the initial data value to a string, cast item values as strings, or explicitly set the compare function to one using a weak comparison (==
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With