vue实现商城秒杀倒计时功能
网络编程 2021-07-04 15:02www.168986.cn编程入门
这篇文章主要介绍了vue实现商城秒杀倒计时功能,非常不错,具有一定的参考借鉴价值,需要的朋友可以参考下
vue实现商城秒杀倒计时功能,效果图如下所示
template代码
<div> <div class="ponent-wrapper" id="flash-sale"> <div class="sale-header"> <div class="countdown-zone"> <div class="countdown-prefix">限時快搶</div> <div class="countdown pure-css-countdown active"> <div class="digits-wrapper hours">11</div> <div class="digits-seperator">月</div> <div class="digits-wrapper minutes">02</div> <div class="digits-seperator">日</div> <div class="digits-seperator">——</div> <div class="digits-wrapper seconds">11</div> <div class="digits-seperator">月</div> <div class="digits-wrapper">03</div> <div class="digits-seperator">日</div> </div> </div> </div> </div> </div>
script代码
export default { data() { return { hou:0, min:0, sec:0, ssec:0, endTime:'', disprArr:[], } }, created(){ let that=this that.time() }, methods:{ time(){ var that=this var interval = setInterval(function timestampToTime(){ var date=(new Date(结束的时间戳)) - (new Date()); //new Date当前的时间戳,也可以换成自定义的时间戳 if (date > 0) { let time = date / 1000; // 获取时、分、秒,毫秒 that.hou = parseInt((time % (60 60 24)) / 3600)<10?('0'+parseInt((time % (60 60 24)) / 3600)):parseInt((time % (60 60 24)) / 3600) that.min = parseInt(((time % (60 60 24)) % 3600) / 60)<10?('0'+parseInt(((time % (60 60 24)) % 3600) / 60)):parseInt(((time % (60 60 24)) % 3600) / 60); that.sec = parseInt(((time % (60 60 24)) % 3600) % 60)<10?('0'+parseInt(((time % (60 60 24)) % 3600) % 60)):parseInt(((time % (60 60 24)) % 3600) % 60); that.ssec= parseInt(((date % (60 60 24)) % 3600) / 60)%10 } else { //活动已结束,全部设置为'00' // console.log("aaa") that.day="00", that.hou="00", that.min="00", that.sec="00" } },100) } }, };
以上所述是长沙网络推广给大家介绍的vue实现商城秒杀倒计时功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,长沙网络推广会及时回复大家的。在此也非常感谢大家对狼蚁SEO网站的支持!
如果你觉得本文对你有帮助,欢迎网络推广网站推广转载,烦请注明出处,谢谢!
编程语言
- 甘肃哪有关键词排名优化购买方式有哪些
- 甘肃SEO如何做网站优化
- 河南seo关键词优化怎么做电话营销
- 北京SEO优化如何做QQ群营销
- 来宾百度关键词排名:提升您网站曝光率的关键
- 卢龙关键词优化:提升您网站排名的策略与技巧
- 山东网站优化的注意事项有哪些
- 四川整站优化怎样提升在搜索引擎中的排名
- 疏附整站优化:提升网站性能与用户体验的全新
- 海南seo主要做什么工作售后服务要做到哪些
- 荣昌百度网站优化:提升您网站的搜索引擎排名
- 河北seo网站排名关键词优化如何做SEO
- 江西优化关键词排名推广售后保障一般有哪些
- 古浪SEO优化:提升你的网站可见性
- 西藏网站排名优化怎么把网站排名在百度首页
- 如何提升阳东百度快照排名:详尽指南