小程序清除定时器无效怎么回事?
data: {
timer: null
},
timer() {
this.setData({
timer: setInterval(() => {
console.log(222222222)
}, 1000)
})
},
onUnload(){
clearInterval(this.data.timer);
},
onHide(){
clearInterval(this.data.timer);
},
onLoad(){
this.timer()
}
这种方式也试了 还是不行 var timer; //页面顶部定义
onUnload(){
clearInterval(this.timer);
},
onHide(){
clearInterval(this.timer);
},
onLoad: function(options) {
var that = this;
this.timer=setInterval(() => {
console.log(222222222)
}, 1000)
}