uniapp密码输入框

uniapp自定义密码输入框

可用于小程序短信验证码输入框、密码数字框…



效果图

在这里插入图片描述


定义组件

提示: 这里把输入框定义为组件,其他可根据需求调整

template
<template>
	<view>
		<view class="password-input-warp fcc">
			<view class="password-input_item fcc" :style="{width: width +'rpx', height: height +'rpx', backgroundColor: backgroundColor}"
				@click="focus = true" v-for="(item, index) in length" :key="index">
				<view class="num" :class="txtStatus ? 'txtColor' : ''" :style="{fontWeight : bold ? 'bold' : 'normal'}" v-if="password.length > index">
					{
  
  { showVal ? password[index] : placeholder }}
				</view>
				<view class="line animation" v-if="password.length == index">|</view>
			</view>

			<input class="input" type="number" :focus="focus" v-model="password" :maxlength="length" @focus="focus = true"
				@blur="focus=false" @input="passwordInput" />
		</view>
	</view>
</template>


js
<script>
	export default {
   
   
		data() {
   
   
			return {
   
   
				focus: false,
				password: ''
			}
		},
		props: {
   
   
			width: {
   
   
				type: [Number, String],
				default: 100,
			},
			height: {
   
   
				type: [Number, String],
				default: 100,
			},
			backgroundColor: {
   
   
				type: String,
				default: 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值