[英]Vue.js dynamic dropdown
How would I make a dynamic dropdown in vue, not sure what I am doing wrong.我将如何在 vue 中进行动态下拉,不确定我做错了什么。
in my html I have...在我的 html 中,我有...
<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....我的 js 看起来像....
new Vue({
el: '#app',
data: {
selected: ["Apache", "Cochise"],
}
})
filters looks like this过滤器看起来像这样
EDIT: the values appear in the html DOM tree in the inspector编辑:值出现在检查器的 html DOM 树中
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>
Note : For future readers, there was also an issue where the normal delimiters for text interpolation needed to be customized in @captnvitman's evnironment.注意:对于未来的读者,还有一个问题是需要在@captnvitman 的环境中自定义文本插值的正常分隔符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.