
wxml:
<view class='content'>
<block wx:for="{{Length}}" wx:key="item">
<input class='iptbox' value="{{Value.length>=index+1?Value[index]:''}}" disabled type="number" catchtap='Tap'/>
</block>
</view>
<input name="password" type="number" class='ipt' maxlength="{{Length}}" focus="{{isFocus}}" bindinput="Focus"/>
<view>
</view>
<button class="resend" disabled="{{disabledFlag}}" data-id="2" bindtap="getVerificationCode">
{{time}}
</button>
wxss:
.content{
display: flex;
justify-content: space-around;
align-items: center;
margin: 0 80rpx;
}
.iptbox{
width: 80rpx;
height: 80rpx;
border-bottom:1rpx solid #ddd;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
font-size: 40rpx;
}
.ipt{
width: 0;
height: 0;
}
js:
Length: 6, //输入框个数
isFocus: true, //聚焦
Value: "",
转载,但是忘记地址了,所以写了原创,请见谅,侵联删
这篇博客介绍了如何使用WXML和WXSS在小程序中实现验证码输入框的美化,包括样式设置和逻辑处理。通过创建多个输入框并结合JS进行交互,如设置输入框数量、聚焦状态以及动态更新验证码倒计时按钮。
441

被折叠的 条评论
为什么被折叠?



