(vue.js)vue中怎么设置select默认选中

<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;
}
})

猜你喜欢

转载自www.cnblogs.com/sharestone/p/9717650.html