小程序验证码动画效果

  • wxml
<view class="code_container">
  <view class="code_box"  data-flag="{{ true }}" bindtap="handleFocus">
    <text class="{{ code[0] ? 'active_code' : ''}}">{{ code[0] }}</text>
    <text class="{{ code[1] ? 'active_code' : ''}}">{{ code[1] }}</text>
    <text class="{{ code[2] ? 'active_code' : ''}}">{{ code[2] }}</text>
    <text class="{{ code[3] ? 'active_code' : ''}}">{{ code[3] }}</text>
    <text class="{{ code[4] ? 'active_code' : ''}}">{{ code[4] }}</text>
    <text class="{{ code[5] ? 'active_code' : ''}}">{{ code[5] }}</text>
    <text class="{{ code[6] ? 'active_code' : ''}}">{{ code[6] }}</text>
    <text class="{{ code[7] ? 'active_code' : ''}}">{{ code[7] }}</text>
  </view>
  <input class="ipt" type="number" focus="{{foucs}}" bindinput="handleInput" bindblur="handleFocus" data-flag="{{ false }}" maxlength="8"/>
</view>
  • wxss
.code_container {
  margin: 20rpx;
  padding: 40rpx 40rpx 48rpx 40rpx;
  background-color: white;
  box-shadow: 0px 10px 10px 0px rgba(0,0,0,0.02);
  border-radius: 16rpx;
}

.code_box {
  display: flex;
  justify-content: space-between;
}

.code_box text {
  width: 70rpx;
  height: 90rpx;
  line-height: 90rpx;
  text-align: center;
  font-size: 70rpx;
  color: #000;
  font-weight: 700;
  border: 1px solid #4780BA;
  border-radius: 10rpx;
}

.ipt {
  width: 0;
}

.active_code {
  border: 1px solid #FF8B1A !important;
}
  • js
const app = getApp()

Page({
  data: {
    foucs: false,
    code: ''
  },

  handleInput({ detail: { value }}) {
    this.setData({ code: value })
  },

  handleFocus({ currentTarget: { dataset: { flag }}}) {
    this.setData({ foucs: flag })
  }
})

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值