web前端全系列 教程
1839个小节阅读:2243.1k
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
输入框
xxxxxxxxxx
<view>
<view class="title">可自动聚焦的input</view>
<input class="uni-input" focus placeholder="自动获得焦点" />
</view>
<view>
<view class="title">键盘右下角按钮显示为搜索</view>
<input class="uni-input" confirm-type="search" placeholder="键盘右下角按钮显示为搜索" />
</view>
<view>
<view class="title">控制最大输入长度的input</view>
<input class="uni-input" maxlength="10" placeholder="最大输入长度为10" />
</view>
<view>
<view class="title">实时获取输入值:{{inputValue}}</view>
<input class="uni-input" @input="onKeyInput" placeholder="输入同步到view中" />
</view>
<view>
<view class="title">控制输入的input</view>
<input class="uni-input" @input="replaceInput" v-model="changeValue" placeholder="连续的两个1会变成2" />
</view>
<view>
<view class="title">数字输入的input</view>
<input class="uni-input" type="number" placeholder="这是一个数字输入框" />
</view>
<view>
<view class="title">密码输入的input</view>
<input class="uni-input" password type="text" placeholder="这是一个密码输入框" />
</view>
<view>
<view class="title">带小数点的input</view>
<input class="uni-input" type="digit" placeholder="带小数点的数字键盘" />
</view>
<view>
<view class="title">身份证输入的input</view>
<input class="uni-input" type="idcard" placeholder="身份证输入键盘" />
</view>
<view>
<view class="title">控制占位符颜色的input</view>
<input class="uni-input" placeholder-style="color:#F76260" placeholder="占位符字体是红色的" />
</view>
xxxxxxxxxx
export default {
data() {
return {
placeholder: '开始输入...',
inputValue: "",
changeValue: '',
}
},
methods: {
onKeyInput(event) {
this.inputValue = event.target.value
},
replaceInput: function(event) {
var value = event.target.value;
if (value === '11') {
this.changeValue = '2';
}
}
}
}
,
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
value | String | 输入框的初始内容 | |
type | String | text | input 的类型 |
placeholder-style | String | 指定 placeholder 的样式 | |
disabled | Boolean | false | 是否禁用 |
placeholder | String | 输入框为空时占位符 | |
disabled | Boolean | false | 是否禁用 |
focus | Boolean | false | 获取焦点 |
@input | EventHandle | 当键盘输入时,触发input事件,event.detail = {value} |
值 | 说明 | 平台差异说明 |
---|---|---|
text | 文本输入键盘 | |
number | 数字输入键盘 | 均支持,App平台、H5平台 3.1.22 以下版本 vue 页面在 iOS 平台显示的键盘包含负数和小数。 |
idcard | 身份证输入键盘 | 微信、支付宝、百度、QQ小程序、快手小程序、京东小程序 |
digit | 带小数点的数字键盘 | 均支持,App平台、H5平台 vue 页面在 iOS 平台显示的键盘包含负数。 |
tel | 电话输入键盘 | 仅App的nvue页面支持 |
safe-password | 密码安全输入键盘 | 微信小程序 |
nickname | 昵称输入键盘 | 微信小程序 |
实时效果反馈
1. uni-app中,输入框键盘输入触发事件是哪一个:
A value
B disabled
C focus
D @input
答案
1=>D