G
G
grigorie19902019-08-31 20:17:54
Vue.js
grigorie1990, 2019-08-31 20:17:54

Is it possible to set a default option in vue if the model value does not match any option value?

Is it possible to set a default option in vue if the model value does not match any option value?
Those. so that when the page loads, if there is no value, then it would immediately overwrite the model.

<select v-model="RefRealValueArr[paramName][index]">
<option :value="null">Нет</option>
<option :value="key" v-for="(value, key) in refValuesChosen">
{{value}}
</option>
</select>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
NiceScript, 2019-09-01
@NiceScript

Of course, I don't know what kind of data array you have there.
But through created, I would implement it like this.
those. in select v-model we make the property definable via a function.
And in it we already carry out the checks we need and derive what we need.
I think by disassembling my code in jsfiddle, you will cope with your task

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question