小程序 - 3秒倒計時跳轉+點擊跳轉

3s倒計時.png

小程序 - 3秒倒計時跳轉+點擊跳轉

wxml

<view>
    <view class="register_success">
        <image src="../../images/register_success.png"></image>
    </view>
    <rich-text>{{success_text}}</rich-text>
    <view style="height:182rpx"></view>
    <view class="next_button">
        <button class="next_button" type="{{buttonType}}" disabled="{{disabled}}"  catchtap="closePage">{{time}}s關閉頁面</button>
    </view>
</view>

js

Page({
    data: {
        success_text : '注冊成功!', 
        time:3,
    },
    onReady: function () {
     //3s后跳轉
     this.data.Time = setInterval(() => {
      this.setData({
        time: --this.data.time
      })
      if (this.data.time <= 0) {
        clearInterval(this.data.Time)
        this.closePage()
      }
    }, 1000)
  },
})

wxss

/* pages/register_success/register_success.wxss */

.register_success {
  width: 186rpx;
  height: 186rpx;
  margin: 0 auto;
  margin-top: 160rpx;
}
.register_success image {
  width: 100%;
  height: 100%;
  display: block;
}
 rich-text {
  text-align: center;
  margin-top: 60rpx;
  font-size: 40urpx;
  color: #505050;
  display: block;
}
.next_button {
  background-color: #ed1b24;
  color: #ffffff;
  margin: 0 60rpx;
  border-radius: 50rpx;
  height: 88rpx;
  line-height: 60rpx;
}
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容