Skip to content

验证码输入框 xCodeInput


在线预览
在线模拟尺寸:

介绍

验证码输入框,截止4.22安卓会自动拉起系统键盘,ios无法使用系统键盘。目前仅配合我的组件键盘可以全局兼容。已向官方返回Input的bug

平台兼容

H5andriodIOS小程序UTSUNIAPP-X SDKversion
☑️☑️☑️☑️4.44+1.1.9

文件路径

ts

@/uni_modules/tmx-ui/components/x-code-input/x-code-input.uvue

使用

ts

<x-code-input></x-code-input>

Props 属性

名称说明类型默认值
autoFocus进入时自动获取焦点,并弹出系统自带的键盘(需要useSysKeyborad=true)。booleanfalse
useSysKeyborad是否使用系统自带的键盘。,如果为false你需要自行配置输入键盘<br>比如使用我的keyborad键盘组件。booleantrue
modelValue当前输入的值string""
maxlength最大长度number4
gutter间距string"8"
width验证码框的宽string"50"
height验证码框的高string"50"
fontColor当前输入项激活时的文字颜色同时也是高亮时的背景色。<br>默认取全局主题string""
darkFontColor暗黑时的主题色,不填写等同fontColorstring""
fontSize文字大小string"21"
round圆角string"8"
bgColorskin = fill时的背景string"#f0f0f0"
darkBgColorskin = fill时的暗黑背景string"#272727"
borderColorskin = outline时的边线颜色string""
darkBorderColorskin = outline时的暗黑边线颜色string""
unBorderColorskin = outline时的边线颜色[非激活时]string"#e3e3e3"
unDarkBorderColorskin = outline时的暗黑边线颜色[非激活时]string"#2c2b2c"
skin``string"outline"
placeShape待输入时的占位形状<br>line线型<br>round圆形<br>空值表示不需要占位符号string"round"

Events 事件

名称参数说明
click-点击框时触发
confirm-输入长度等于指定长度时触发
change-变动时触发
update:modelValue-等同vmodel,可与我的keyborad键盘配合使用。

Slots 插槽

名称说明数据

Ref 方法

名称参数返回值说明

示例文件路径

json

/pages/qita/code-input

示例源码

uvue
vue
<template>
	<!-- #ifdef APP -->
	<scroll-view style="flex:1">
	<!-- #endif -->
	<!-- #ifdef MP-WEIXIN -->
	<page-meta :page-style="`background-color:${xThemeConfigBgColor}`">
		<navigation-bar :background-color="xThemeConfigNavBgColor" :front-color="xThemeConfigNavFontColor"></navigation-bar>
	</page-meta>
	<!-- #endif -->
		<x-sheet>
			<x-text font-size="18" class=" text-weight-b mb-8">验证码输入 xCodeInput</x-text>
			<x-text  color="#999999" >提供了两种方式,自带输入框输入,以及配合我的keyborad键盘。</x-text>
		</x-sheet>
		
		<x-sheet>
			<x-text font-size="18" class=" text-weight-b mb-8">自动拉起系统键盘</x-text>
			<x-code-input @confirm="ok" gutter="4" :maxlength="6" width="45" :autoFocus="true"></x-code-input>
		</x-sheet>
		
		<x-sheet>
			<x-text font-size="18" class=" text-weight-b mb-12">关闭系统键盘使用组件键盘</x-text>
			<x-code-input place-shape="line" @click="showkey=true" @confirm="showkey = false" v-model="value" :useSysKeyborad="false" skin="fill"></x-code-input>
		</x-sheet>
		
		
		
		<x-keyboard-number :max-len="4" v-model:modelShow="showkey" v-model="value"></x-keyboard-number>
		<view style="height: 400px;"></view>
	<!-- #ifdef APP -->
	</scroll-view>
	<!-- #endif -->
</template>

<script>
	export default {
		data() {
			return {
				value:"",
				showkey:false
			}
		},
		methods: {
			ok(){
				uni.showToast({
					title:"验证成功",
					mask:true
				})
			}
		}
	}
</script>

<style>

</style>
最近更新