v-model 可以在以下三处使用
- input(type='text',type='radio', type='checkbox')
- textarea
- select
input
写法1:
label 标签的 for 属性里面填的是相应 input 的 id
![1d6b28c1e276e3e8a2c8e4d80eabfa49.png](https://img-blog.csdnimg.cn/img_convert/1d6b28c1e276e3e8a2c8e4d80eabfa49.png)
这样单击"男"也会直接选中 radio 中的标签;
写法2:
name="sex"
当两个 input 的 name属性设置的一样, 他们就是一组 radio 了只能单选
![a1121829d451adaee7eea7e9c22cdf68.png](https://img-blog.csdnimg.cn/img_convert/a1121829d451adaee7eea7e9c22cdf68.png)
![207880407e826390dbc35b892a34e8d2.png](https://img-blog.csdnimg.cn/img_convert/207880407e826390dbc35b892a34e8d2.png)
使用 v-model 绑定, 来替代原来的 name
![8e4d4f3170ace1f5f450b4fa180d4c32.png](https://img-blog.csdnimg.cn/img_convert/8e4d4f3170ace1f5f450b4fa180d4c32.png)
checkbox
sex 的值是一个数组, 会自动插入到数组里
![daae0d9d6ab929a9bc5ee0b04e4ec996.png](https://img-blog.csdnimg.cn/img_convert/daae0d9d6ab929a9bc5ee0b04e4ec996.png)
textarea
![1a71e198060850b024e749f4d5d82179.png](https://img-blog.csdnimg.cn/img_convert/1a71e198060850b024e749f4d5d82179.png)
select
select 就必定带着 option
![5b07f1bd648ccdb039c798bc61128c1d.png](https://img-blog.csdnimg.cn/img_convert/5b07f1bd648ccdb039c798bc61128c1d.png)
多选就需要加一个 multiple 属性
![7a6621a9afe3b0176969f05032c5c4b4.png](https://img-blog.csdnimg.cn/img_convert/7a6621a9afe3b0176969f05032c5c4b4.png)