pu369com

JS 定时器-setInterval、clearInterval、setTimeout

在微信小程序里写的:

// pages/splash/splash.js
const app = getApp()
Page({
  data: {
    remainSecond: 3

  },
  // 页面渲染完成后 调用
  onReady: function() {
    let that = this
    let interval = setInterval(function() {
      let rs = that.data.remainSecond
      rs--
      if (rs < 0) {
        clearInterval(interval);
      }
      this.setData({
        remainSecond: rs
      })
    }.bind(this), 1000)
    setTimeout(function() {
      wx.reLaunch({
        url: '../write/write',
      })
    }, 3000)

  }
})

 

posted on 2019-08-26 12:42  pu369com  阅读(202)  评论(0编辑  收藏  举报

导航