当前位置:网站首页>表单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>
边栏推荐
- What if Fiddler fails to listen to the interface
- C WinForm reads the resources picture
- 良/恶性乳腺肿瘤预测(逻辑回归分类器)
- matlab axis坐标轴相关设置详解
- 通过中金证券经理的开户二维码开股票账户安全吗?还是去证券公司开户安全?
- Can you do these five steps of single cell data cleaning?
- MySQL企业级参数调优实践分享
- 捷码赋能案例:湖南天辰产研实力迅速提升!实战玩转智慧楼宇/工地等项目
- Pat class B 1013
- 【剑指Offer】47. 礼物的最大价值
猜你喜欢

发射,接收天线方向图

webserver流程图——搞懂webserver各模块间调用关系

An analysis of C language functions

golang - new和make的区别
![[try to hack] kill evaluation](/img/93/e623e25dc4dec1f656227c7651577e.png)
[try to hack] kill evaluation

The file or assembly 'cefsharp.core.runtime.dll' or one of its dependencies could not be loaded. Is not a valid Win32 Application. (exception from hresult:0x800700c1)

Teach you how to transplant tinyriscv to FPGA

ClickOnce error deploying ClickOnce application - the reference in the manifest does not match the identity of the downloaded assembly

halcon之区域:多种区域(Region)特征(6)

Sentinel
随机推荐
Systematic learning + active exploration is the most comfortable way to get started!
Teach you how to transplant tinyriscv to FPGA
思源笔记订阅停止直接删云端数据嘛?
Instructions for vivado FFT IP
Golang uses Mongo driver operation -- Query (array related)
计数质数[枚举 -> 空间换时间]
Detailed explanation of MATLAB axis coordinate axis related settings
Swing UI container (I)
抓出那些重复的基因
[AI application] detailed parameters of Jetson Xavier nx
MySQL read / write separation configuration
matlab axis坐标轴相关设置详解
如何找到外文文献对应的中文文献?
At the beginning of reading English literature, I would like to ask you how you should read it in the first place?
How to use the apipost script - global variables
An analysis of C language functions
Prediction of benign / malignant breast tumors (logistic regression classifier)
零基础自学SQL课程 | CASE函数
MySQL企业级参数调优实践分享
圖的存儲結構