// pages/audit/audit.js
Page({
  数据
  data: {
    time: 3,
    timer: null
  },

  onLoad: function (options) {},
   onShow() { let _this
= this; this.setData({ timer: setInterval(() => { _this.setTimeCount() }, 1000) }) },
  定时器 setTimeCount: function () { let time
= this.data.time time--; if (time <= 0) { wx.redirectTo({ url: '/pages/index/index' }) return false; } this.setData({ time: time, }) },
  销毁定时器 onUnload: function () { clearInterval(
this.data.timer); }, gopage() { wx.redirectTo({ url: '/pages/index/index' }) } })

取消由 setInterval 设置的定时器。

相关文章:

  • 2021-08-25
  • 2022-02-08
  • 2021-09-20
  • 2021-04-26
  • 2021-12-05
  • 2021-12-05
  • 2021-12-05
  • 2021-11-18
猜你喜欢
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2021-12-16
相关资源
相似解决方案