Vue-select: Add a Value Key Prop

Created on 19 Feb 2020  路  2Comments  路  Source: sagalbot/vue-select

Hello,

There already exists the prop to specify a custom label key, but nothing for value. I'm trying to populate the select with a recordset straight from a DB, and it doesn't have a "value" field. I really don't want to have to transform the data before utilizing the select.

Thank you!
Chris

Most helpful comment

Hi. I've wasted a lot of time looking for this question, I think in the docs is not very clear the usage of reduce prop, maybe emphasizing it will replace the resultant value in the v-model would help.

In this example when your choose an option, the selection prints a number and not the country code, as it must be, it causes a lot of confusion.

Thanks.

All 2 comments

https://vue-select.org/guide/values.html#transforming-selections

The component selects an entire object by default. If you want the v-model result to just be a single key of that object, you can use reduce.

Hi. I've wasted a lot of time looking for this question, I think in the docs is not very clear the usage of reduce prop, maybe emphasizing it will replace the resultant value in the v-model would help.

In this example when your choose an option, the selection prints a number and not the country code, as it must be, it causes a lot of confusion.

Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lau-a picture lau-a  路  3Comments

xuwenhao picture xuwenhao  路  3Comments

davidalvarezr picture davidalvarezr  路  3Comments

edalzell picture edalzell  路  3Comments

jluterek picture jluterek  路  3Comments