无光标验证码输入框

该代码段展示了一个Vue.js组件,用于创建一个输入框(input)并动态显示输入的6位数字。每个数字被单独显示在带有不同类名的视图(view)中,根据输入长度应用激活状态的样式。CSS定义了输入框和数字框的样式。
摘要由CSDN通过智能技术生成

1.静态结构

<view class="iptWarp">
	<input class="ipt" v-model="code" type="number" maxlength="6" value="" />
	<view class="box flex">
		<view :class="code.length >= 1 ? 'itemBox act' : 'itemBox ' ">{{code.substring(0,1)}}</view>
		<view :class="code.length >= 2 ? 'itemBox act' : 'itemBox ' ">{{code.substring(1,2)}}</view>
		<view :class="code.length >= 3 ? 'itemBox act' : 'itemBox ' ">{{code.substring(2,3)}}</view>
		<view :class="code.length >= 4 ? 'itemBox act' : 'itemBox ' ">{{code.substring(3,4)}}</view>
		<view :class="code.length >= 5 ? 'itemBox act' : 'itemBox ' ">{{code.substring(4,5)}}</view>
		<view :class="code.length >= 6 ? 'itemBox act' : 'itemBox ' ">{{code.substring(5,6)}}</view>
	</view>
</view>
  1. js获取code
<script>
export default {
	data() {
		return {
			code: '',
		}
	}
}
</script>

3.css

.iptWarp {
	position: relative;
		height: 100rpx;
		text-align: center;
	
		.ipt {
			position: absolute;
			opacity: 0;
			width: 100%;
			height: 100%;
		}
	
		.box {
			.itemBox {
				flex: 1;
				height: 100rpx;
				line-height: 100rpx;
				margin: 0 10rpx;
				border-bottom: 2rpx solid #EEEEEE;
				color: #FFFFFF;
				&.act {
					border-bottom: 2rpx solid #AE3523;
				}
			}
		}
	}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值