<div id="app">
<form @submit.prevent="demo">
<label for="name" >姓名:</label>
<input type="text" name="name" id="name" v-model.trim="userInfo.account"><br>
<label for="pwd">密码:</label>
<input type="password" name="name" id="pwd" v-model="userInfo.password"><br>
年龄:
<input type="number" name="age" id="" v-model.number="userInfo.age" value="age"><br>
性别:
男<input type="radio" name="sex" id="" v-model="userInfo.sex" value="male">
女<input type="radio" name="sex" id="" v-model="userInfo.sex" value="female"><br>
爱好:
学习:<input type="checkbox" name="" id="demo"v-model="userInfo.hobby" value="study">
打游戏:<input type="checkbox" name="" id=""v-model="userInfo.hobby" value="game">
吃饭:<input type="checkbox" name="" id=""v-model="userInfo.hobby" value="eat"><br>
所属校区:<select v-model="userInfo.city">
<option value="">请选择校区</option>
<option value="bj">北京</option>
<option value="nj">南京</option>
<option value="sh">上海</option>
</select><br>
其他:<textarea name="" id="" cols="30" rows="5" v-model.lazy="userInfo.other"></textarea><br>
<input type="checkbox" v-model="userInfo.agree">阅读并接受<a href="http://baidu.com">用户协议</a><br>
<button>提交</button>
</form>
</div>
</body>
<script>
var app= new Vue({
el:'#app',
data: {
userInfo:{
account:'',
password:'',
age:'',
sex:'male',
hobby:['study'],
city:'bj',
other:'',
agree:''
}
},
methods: {
demo(){
console.log(JSON.stringify(this.userInfo))
//提交到后台处理
}
},
})
</script>
修饰符: