当前位置:网站首页>表单form 和 表单元素(input、select、textarea等)
表单form 和 表单元素(input、select、textarea等)
2022-06-27 21:25:00 【qq_46302247】

<template>
<div class="profile">
<form>
<!-- label for="account" ,当点击label时,id="account"的元素会聚焦 -->
<label for="account">账号:</label>
<input type="text" v-model="userInfo.account" id="account"/><br/><br/>
<label for="password">密码:</label>
<input type="text" v-model="userInfo.password" id="password"/><br/><br/>
性别:
<label for="male">男:</label>
<!-- v-model.trim去掉首位的空格 -->
<input type="radio" v-model.trim="userInfo.sex" value="male" name="sex" id="male"/>
<label for="female">女:</label>
<input type="radio" v-model="userInfo.sex" value="female" name="sex" id="female"/><br/><br/>
<label for="age">年龄:</label>
<!-- type="number" 控制input只能输入数字、小数点和e/E,+,- 等;但是value值的类型依然是string;v-model.number将输入的数字转为number类型 -->
<!-- 所以 type="number" 和 v-model.number要一起用 -->
<!-- onkeyup="value=value.replace(/[^\d]/g, '')" 可以控制 input不能输入小数点和e/E,+,- 等,只能输入数字;-->
<input type="number" v-model.number="userInfo.age" id="age" onkeyup="value=value.replace(/[^\d]/g, '')"/><br/><br/>
爱好:
<label for="game">打游戏</label>
<input type="checkbox" v-model="userInfo.hobby" value="game" id="game"/>
<label for="run">跑步</label>
<input type="checkbox" v-model="userInfo.hobby" value="run" id="run"/>
<label for="eat">吃饭</label>
<input type="checkbox" v-model="userInfo.hobby" value="eat" id="eat"/><br/><br/>
所属校区:
<select v-model="userInfo.school">
<option value="">请选择校区</option>
<option value="beijing">北京</option>
<option value="shanghai">上海</option>
<option value="hangzhou">杭州</option>
</select><br/><br/>
<!-- v-model.lazy 失去焦点时,再把最新的value值给userInfo.other -->
其他信息:<textarea v-model.lazy="userInfo.other"></textarea><br/><br/>
<input type="checkbox" v-model="userInfo.agreement"/>阅读并接受<a href="http://www.baidu.com">用户协议</a><br/><br/>
<!-- form中的button有刷新页面的默认功能,所以需要用click.prevent -->
<button @click.prevent="submit">提交</button>
</form>
</div>
</template>
<script>
export default {
data() {
return {
userInfo: {
account: '',
password: '',
sex: 'male',
age: '',
hobby: [],
school: '',
other: '',
agreement: ''
}
}
},
methods: {
submit() {
console.log(this.userInfo);
}
}
}
</script>
边栏推荐
- Is it safe to open a stock account through the account opening QR code of CICC securities manager? Or is it safe to open an account in a securities company?
- N methods for obtaining effective length of genes
- Usage of vivado vio IP
- Structure de stockage des graphiques
- Safe, fuel-efficient and environment-friendly camel AGM start stop battery is full of charm
- ASP.NET仓库进销存ERP管理系统源码 ERP小程序源码
- 获取基因有效长度的N种方法
- Feign implements path escape through custom annotations
- 华泰证券在网上开户安全吗?
- VirtualBox extended dynamic disk size pit
猜你喜欢
随机推荐
Sécurité, économie de carburant et protection de l'environnement chameau
通过中金证券经理的开户二维码开股票账户安全吗?还是去证券公司开户安全?
文献综述如何挑选文献进行阅读,比如我的检索结果有200多篇根本看不完,如何进行文献挑选呢?...
An analysis of C language functions
[PCL self study: segmentation4] point cloud segmentation based on Min cut
Excel print settings public header
搭建开源美观的数据库监控系统-Lepus
[PCL self study: Segmentation3] PCL based point cloud segmentation: region growth segmentation
[learn FPGA programming from scratch -48]: Vision - development and application of intelligent sensors
Solve the cross domain problem of the new version of chrome: Cookie loss and samesite attribute problem "recommended collection"
Systematic learning + active exploration is the most comfortable way to get started!
SQL中IS NOT NULL与!=NULL的区别
vivado VIO IP的用法
[PCL self study: pclplotter] pclplotter draws data analysis chart
Const keyword and its function (usage), detailed explanation of C language const
PAT乙级1013
ASP.NET仓库进销存ERP管理系统源码 ERP小程序源码
【AI应用】NVIDIA GeForce RTX 3060的详情参数
Google Earth Engine(GEE) 03-矢量数据类型
Zero foundation self-study SQL course | case function







