select动态绑定vue.js
动态选项,用 v-for 渲染:{{ option.text }}Selected: {{ selected }}new Vue({el: '#demo',data: {selected: 'A',options: [{ text: 'One', value: 'A' },{ text: 'Two',
·
动态选项,用 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' }
]
}
})
更多推荐
已为社区贡献15条内容
所有评论(0)