frankdevhub / frankdevhub.github.io

Blog template powered by jekyll to share the interesting stories in life (基于Jekyll的模板引擎的维基风格的个人博客,记录分享生活中的新鲜故事)
http://blog.frankdevhub.site
MIT License
5 stars 3 forks source link

前端如何写一个精确的倒计时 #14

Open frankdevhub opened 5 years ago

frankdevhub commented 5 years ago

https://www.frankdevhub.site/2016/11/25/how-to-write-a-count-down/

关于写倒计时大家可能都都比较熟悉,使用 setTimeout 或 setInterval 就可以搞定。几秒钟或者几分钟的倒计时这样写没有问题,但是如果是长时间的倒计时,这样写就会不准确。如果用户修改了他的设备时间,这样的倒计时就没有意义了。今天就说说写一个精确的倒计时的方法。