当前位置:网站首页>17_ Collect form data
17_ Collect form data
2022-07-20 06:55:00 【ID does not exist.】
Collect form data
Collect form data :
1. if :, be v-model The collection is value value , What the user enters is value value .
2. if :, be v-model The collection is value value , And configure the label value value .
3. if :
(1) No configuration input Of value attribute , So the collection is checked( Check or Uncheck , Boolean value )
(2) To configure input Of value attribute :
v-model The initial value of is a non array , So the collection is checked( Check or Uncheck , Boolean value )
v-model The initial value of is an array , So the collection is value Array of components
4.v-model The three modifiers of :
lazy: Lose focus and collect data
number: The input string is converted to a valid number
trim: Input the first and last spaces to filter
<body>
<div id="root">
<form @submit.prevent="demo">
account number :<input type="text" v-model.trim="userInfo.account"> <br/><br/>
password :<input type="password" v-model="userInfo.password"> <br/><br/>
Age :<input type="number" v-model.number="userInfo.age"> <br/><br/>
Gender :
male <input type="radio" name="sex" v-model="userInfo.sex" value="male">
Woman <input type="radio" name="sex" v-model="userInfo.sex" value="female"> <br/><br/>
hobby :
Study <input type="checkbox" v-model="userInfo.hobby" value="study">
Play the game <input type="checkbox" v-model="userInfo.hobby" value="game">
having dinner <input type="checkbox" v-model="userInfo.hobby" value="eat">
<br/><br/>
Campus
<select v-model="userInfo.city">
<option value=""> Please select Campus </option>
<option value="beijing"> Beijing </option>
<option value="shanghai"> Shanghai </option>
<option value="shenzhen"> Shenzhen </option>
<option value="wuhan"> wuhan </option>
</select>
<br/><br/>
Other information :
<textarea v-model.lazy="userInfo.other"></textarea> <br/><br/>
<input type="checkbox" v-model="userInfo.agree"> Read and accept <a href="http://www.atguigu.com">《 User agreement 》</a>
<button> Submit </button>
</form>
</div>
</body>
<script type="text/javascript">
Vue.config.productionTip = false
new Vue({
el:'#root',
data:{
userInfo:{
account:'',
password:'',
age:18,
sex:'female',
hobby:[],
city:'beijing',
other:'',
agree:''
}
},
methods: {
demo(){
console.log(JSON.stringify(this.userInfo))
}
}
})
</script>
边栏推荐
猜你喜欢
随机推荐
(动态规划系列)剑指 Offer 48. 最长不含重复字符的子字符串
Activiti工作流网关
[haoi2012] volume adjustment (up to backpack)
E2. Escape The Maze (hard version) (思维 + 最短路)
Shell query Prometheus data
tsconfig常用配置全解
Based on yarn1 Sharing of monorepo practice of X
这几款实用的安全浏览器插件,让你效率提高
c语言---程序环境与预处理
Mark and Lightbulbs(思维)
微信小程序-获取用户位置(经纬度+所在城市)
BigDecimal使用
洛谷每日三题之第六天
LeetCode Algorithm 147. 对链表进行插入排序
pdf.js 使用介绍
【C语言刷LeetCode】814. 二叉树剪枝(M)
Mysql database engine analysis
U++ using the SetTimer function
E. Split Into Two Sets(二分图性质 + 种类并查集(扩展域))
CD 从抓轨到搭建流媒体服务器 —— 以《月临寐乡》为例