sleep.js 265 B

12345678910111213141516
  1. /**
  2. * 作者:tmzdy
  3. * 延时操作
  4. * @param {Number} wait = [500] 延时
  5. */
  6. function sleep(wait=500){
  7. let timid = null;
  8. clearTimeout(timid);
  9. return new Promise((res,rej)=>{
  10. timid = setTimeout(function() {
  11. res();
  12. }, wait);
  13. })
  14. }
  15. export default sleep;