Answer the question
In order to leave comments, you need to log in
How to add a value attribute to only the first option tag?
Hello.
I'm trying to make a drop down list from the documentation. Following the recommendation, I want to add the disabled and value="" attributes to the first option . It turned out to make the item inactive, but how to display or hide attributes, in particular value , depending on the index ? My example
Once again the task in a nutshell: having an array
options: [
"Learn JavaScript",
"Learn Vue",
"Play around in JSFiddle",
"Build something awesome"
]
Answer the question
In order to leave comments, you need to log in
<option
v-for="(n, i) in options"
v-text="n"
v-bind="!i && { disabled: true, value: '' }"
></option>
<option disabled value="">выбирай!</option>
<option v-for="n in options">{{ n }}</option>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question