(vue.js)vue中怎么设置select默认选中
<div><select v-model="selected"><option v-for="opt in options" v-bind:value="opt.value">{{opt.text}}</option>&
·
<div>
<select v-model="selected">
<option v-for="opt in options" v-bind:value="opt.value">{{opt.text}}</option>
</select>
<br>
<span>Selected: {{ selected }}</span>
</div>
var options = [
{ text: 'A-label', value: 'A' },
{ text: 'B-label', value: 'B' },
{ text: 'C-label', value: 'C' }
];
new Vue({
el: '#app',
data: {
selected: 'A',
options: []
},
created: function(){
this.options = options;
}
})
更多推荐
已为社区贡献3条内容
所有评论(0)