js 实现sleep睡眠函数

function sleep(delay) {   //delay:传入等待秒数
          var start = (new Date()).getTime();  //获取函数刚开始秒数
          while ((new Date()).getTime() - start < delay) {   //当当前时间减去函数刚开始时间小于等待秒数时,循环一直进行
          continue;
          }

猜你喜欢

转载自blog.csdn.net/chen1042246612/article/details/88204592