P
P
paradoks922018-08-31 14:25:02
Vue.js
paradoks92, 2018-08-31 14:25:02

Vue js how to show option in select selected by default?

Has this Select:

<select class="form-control"  v-model="selectedSport" v-on:change="onChange" :class="{ 'borderRed': trueFlagSport}">
                                            <option value="" hidden selected disabled >Выбери спорт</option>
      <option v-for="(item, index) in itemsSport" :key="index" :value="item.value">@{{item.name}}</option>
                                            </select>

By default, I need to select option: "Choose a sport". But something doesn't work.
I'm not very good at Vue.js, but when I remove the v-model, everything is ok.
What we have now:
5b89253b3792e704817314.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-08-31
@paradoks92

Specifying the selected attribute is pointless - v-model ignores it. Instead, set the initial value of the selectedSport property to an empty string - just like the value of the option you want.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question