It's been hours that I'm trying to get the id of the selected option in v-select, but it returns me the object not the id. Is there any way to get only the Id (object Id) of the selected option?
I already checked the documentation site: https://sagalbot.github.io/vue-select/docs/
I also checked the various examples in: https://codepen.io/collection/nrkgxV/
But so far I have not found the concrete solution to my problem. What is missing or am I doing wrong?
My code:
<template>
<div>
<v-select
v-model="selectedId"
:options="items"
label="name"
></v-select>
</div>
</template>
<script>
export default {
data () {
return {
items: [
{id: 1, name: "User 1", creator_id: 3},
{id: 2, name: "User 2", creator_id: 1},
{id: 4, name: "User 3", creator_id: 3},
],
selectedId: '',
...
}
}
selectedId
. Don't read data from the DOM in Vue; read it from the component's scoped data. – CounteractselectedId.id
? – Alterablev-select
(demo). – Alterable