Search code examples
javascriptvue.jsvuejs3vue-select

option selected with vue-select and get value in function


I´m trying to create a select with this library, but my problem it´s that i need get info from option selected and call other function to add tr in table. I´m working with vue js 3 and composition API.

i can show, that if i use this code:

 <v-select :value="selected" :options="getAllItems" label="name" @change="setSelected($event)"></v-select>
>

i can select my option and i can show it in my select selected. but not call to my function setSelected and i want in this function receibe all information option selected.

My function:

const setSelected = (event) => {
        console.log(event.target)
    }

if i use <v-select v-model="selected" :options="getAllItems" label="name" @change="setSelected($event)"></v-select> never can show option selected in input and i can´t call to function... It´s my first time with this library.

Thanks for readme and sorry for my bad english


Solution

  • apparently in vue3, the prop value was renamed to modelValue and not updated on the docs. Had my one share of pain while dealing with this one!