Search code examples
vue-select

Vue select not highlight selected Item in Dropdown


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?


Solution

  • You can add a v-model="someVar" and set it to some default value of your choice if this is what you're looking for. Check the link for reference.