美文网首页
VueJS实践:Select动态绑定

VueJS实践:Select动态绑定

作者: 寒剑飘零 | 来源:发表于2017-04-01 23:56 被阅读524次

动态选项,用 v-for 渲染:

<select v-model="selected">
<option v-for="option in options" v-bind:value="option.value">
{{ option.text }}
</option>
</select>
<span>Selected: {{ selected }}</span>

new Vue({
el: '#demo',
data: {
selected: 'A',
options: [
{ text: 'One', value: 'A' },
{ text: 'Two', value: 'B' },
{ text: 'Three', value: 'C' }
]
}
})

相关文章

网友评论

      本文标题:VueJS实践:Select动态绑定

      本文链接:https://www.haomeiwen.com/subject/ipbwottx.html