vue学习之表单数据自动收集
作者:互联网
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>菜鸟教程(runoob.com)</title>
<script src="vue.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="demo">
<form action="/XXX">
<span>用户名:</span>
<input type="text" v-model="username" /> <br>
<span>密码:</span>
<input type="password" v-model="pwd"/> <br>
<span>性别:</span>
<input type="radio" id="female" value="女"v-model="sex">
<label for="female">女</label>
<input type="radio" id="male" value="男" v-model="sex">
<label for="male">男</label><br>
<span>爱好:</span>
<input type="checkbox" id="basket" value='basket' v-model="likes"/>
<label for="basket">篮球</label>
<input type="checkbox" id="foot" value="foot" v-model="likes"/>
<label for="basket">足球</label>
<input type="checkbox" id="pingpang" value="pingpang" v-model="likes"/>
<label for="basket">乒乓球</label><br>
<span>城市:</span>
<select>
<option value="">未选择</option>
</select><br>
<span>介绍:</span>
<textarea rows="10"></textarea><br><br>
<input type="submit" value="注册 " />
</form>
</div>
<script type="text/javascript">
//Vue只是监视了persons的改变,没有监视数组内部数据的改变
//Vue重写了数组中的一系列改变数组内部数据的方法(先调用原生,在更新页面)----》数组内部改变,界面自动变化
new Vue({
el:'#demo',
data:{
username:'',
pwd:'',
sex:'男',
likes:[]
}
})
</script>
</body>
</html>
标签:vue,内部,收集,表单,改变,Vue,数组,监视,数据 来源: https://blog.csdn.net/PhilsphyPrgram/article/details/122113847