Front-end/vue/8-表单输入绑定.md

28 lines
452 B
Markdown
Raw Normal View History

2023-10-19 02:19:45 -04:00
## v-model
```html
<div id="example-6">
<select v-model="selected">
<option v-for="option in options" v-bind:value="option.value">
{{ option.text }}
</option>
</select>
<span>Selected: {{ selected }}</span>
</div>
```
```js
new Vue({
el: 'example-6',
data: {
selected: 'A',
options: [
{ text: 'One', value: 'A' },
{ text: 'Two', value: 'B' },
{ text: 'Three', value: 'C' }
]
}
})
```