<var id="xvh3p"><noframes id="xvh3p"><var id="xvh3p"></var><listing id="xvh3p"><strike id="xvh3p"><listing id="xvh3p"></listing></strike></listing>
<var id="xvh3p"><strike id="xvh3p"><var id="xvh3p"></var></strike></var><th id="xvh3p"><strike id="xvh3p"><th id="xvh3p"></th></strike></th>
<span id="xvh3p"><noframes id="xvh3p"><dl id="xvh3p"></dl>
<span id="xvh3p"><noframes id="xvh3p">
<dl id="xvh3p"><noframes id="xvh3p">
<listing id="xvh3p"><noframes id="xvh3p"><listing id="xvh3p"><strike id="xvh3p"><listing id="xvh3p"></listing></strike></listing><th id="xvh3p"><strike id="xvh3p"><th id="xvh3p"></th></strike></th>
<th id="xvh3p"><strike id="xvh3p"></strike></th>
<dl id="xvh3p"><noframes id="xvh3p">
<th id="xvh3p"><noframes id="xvh3p">

观点

互联网+时代,说建站,谈运营与网络营销

微信小程序定时器的使用/清除,关闭页面的清除

时间:今天 (00:11)

设置定时器:setInterval(function,time),清除clearInterval(intervalName)
我们设置定时器的时候,需要在data里面设置,以便于全局清除

定时器在关闭页面的时候并不会清除,所以要监听页面的关闭,去清除定时器。监听页面卸载函数onUnload()

Page({

  /**
   * 页面的初始数据
   */   data: {     order_sn:null,     interval:'' 

}

设置定时器的时候

this.setData({

  interval : setInterval(() => {           //业务逻辑
        }, 3000) }) 

清除的时候


clearInterval(this.data.interval)


监听页面卸载时清除定时器 

 /* 生命周期函数--监听页面卸载*/

  onUnload: function () {     clearInterval(this.data.interval)   }
0
首页
案例
关于
联系