Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue select not highlight selected Item in Dropdown

Tags:

vue-select

I'm using vue-select. When I load the form, the item in the dropdown is not selected. When I open the dropdown, the first item is selected:

enter image description here

When i select an item, and the reopen the dropdown, the item is selected (as expected)

enter image description here

                    <div class="col-lg-6">
                        <div class="form-group row">
                            <label for="customer" class="col-sm-2 col-form-label">Kunde</label>
                            <div class="col-sm-10">
                                <v-select :options="customers" :reduce="name => name.id"  v-model="form.customer_id" id="customer" label="name" placeholder="Kunde" :class="$vSelectStyle($v.form.customer_id)"></v-select>

                                <template v-if="$v.form.customer_id.$error" >
                                    <p class="text-danger" v-if="!$v.form.customer_id.required">
                                        Name ist erforderlich!
                                    </p>
                                </template>
                            </div>
                        </div>
                    </div>

What i have to do that the item is selected the first time?

like image 932
Peter Avatar asked Oct 21 '25 09:10

Peter


1 Answers

Just add the style/css to the selected..

.vs__dropdown-option--selected {
  background-color: red  !important;
}

See sample here: Fiddle

This also works in multiple.

like image 89
Donnise David Avatar answered Oct 24 '25 20:10

Donnise David



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!