Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
74
rated 0 times [  77] [ 3]  / answers: 1 / hits: 22764  / 7 Years ago, mon, april 3, 2017, 12:00:00

How would I make a dynamic dropdown in vue, not sure what I am doing wrong.



in my html I have...



<div id=app>
<select v-model=selected>
<option disabled value=>Please select one</option>
<option v-for=item in selected></option>
</select>




and my js looks like....



new Vue({
el: '#app',
data: {
selected: [Apache, Cochise],
}
})


filters looks like this
enter



EDIT:
the values appear in the html DOM tree in the inspector
enter



but not in the dropdown
enter


More From » dynamic

 Answers
6

Try this.


new Vue({
el: '#app',
data: {
filters: filters,
selectedValue: null
}
})

<div id="app">
<select v-model="selectedValue">
<option disabled value="">Please select one</option>
<option v-for="item in filters" :value="item">{{item}}</option>
</select>
</div>

Example.


Note: For future readers, there was also an issue where the normal delimiters for text interpolation needed to be customized in @captnvitman's evnironment.


[#58281] Saturday, April 1, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ansleyk

Total Points: 42
Total Questions: 100
Total Answers: 83

Location: Angola
Member since Wed, Apr 13, 2022
2 Years ago
ansleyk questions
;