连续点击造成定时器叠加的解决方案

var timer = null;// typrof timer == 'object';

timer = setInterval(function() {

  //...

}, 1000);//  typeof timer == 'number'

clearInterval(timer);// typeof timer == 'number'

timer = null; // typrof timer == 'object';

即在清楚定时器的时候加上timer = null 在开启定时器的时候判断 if(typeof timer  == 'object'){

  //开启定时器

}

原文地址:https://www.cnblogs.com/pcd12321/p/5128153.html