动态选项,用 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',
扫描二维码关注公众号,回复: 2233668 查看本文章 -
data: {
-
selected: 'A',
-
options: [
-
{ text: 'One', value: 'A' },
-
{ text: 'Two', value: 'B' },
-
{ text: 'Three', value: 'C' }
-
]
-
}