Bootstrap

微信小程序页面离开清除定时器

countDown: function(){ // 倒计时
        var time = this.data.time;
        this.setData({
            clock: setInterval(function () {
                var minu = parseInt(time.split(':')[0]);
                var seconds = parseInt(time.split(':')[1]);
                var timeSum = minu * 60 + seconds;
                // timeSum--;
                console.log(timeSum);
                // minu = parseInt(timeSum / 60);
            },1000)
        })
        
    },
    onHide: function () {
        clearInterval(this.data.clock);
    },
    onUnload: function () {
        clearInterval(this.data.clock);
    },
;