vue實(shí)現(xiàn)商城秒殺倒計(jì)時(shí)功能
vue實(shí)現(xiàn)商城秒殺倒計(jì)時(shí)功能,效果圖如下所示:
template代碼
<div> <div class="component-wrapper" id="flash-sale"> <div class="sale-header"> <div class="countdown-zone"> <div class="countdown-prefix">限時(shí)快搶</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(結(jié)束的時(shí)間戳)) - (new Date()); //new Date當(dāng)前的時(shí)間戳,也可以換成自定義的時(shí)間戳 if (date > 0) { let time = date / 1000; // 獲取時(shí)、分、秒,毫秒 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 { //活動(dòng)已結(jié)束,全部設(shè)置為'00' // console.log("aaa") that.day="00", that.hou="00", that.min="00", that.sec="00" } },100) } }, };
總結(jié)
以上所述是小編給大家介紹的vue實(shí)現(xiàn)商城秒殺倒計(jì)時(shí)功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺(jué)得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
- vue+vant實(shí)現(xiàn)商品列表批量倒計(jì)時(shí)功能
- Vue寫(xiě)一個(gè)簡(jiǎn)單的倒計(jì)時(shí)按鈕功能
- 簡(jiǎn)單實(shí)現(xiàn)vue驗(yàn)證碼60秒倒計(jì)時(shí)功能
- vue2.0實(shí)現(xiàn)倒計(jì)時(shí)的插件(時(shí)間戳 刷新 跳轉(zhuǎn) 都不影響)
- vue實(shí)現(xiàn)時(shí)間倒計(jì)時(shí)功能
- 基于vue的短信驗(yàn)證碼倒計(jì)時(shí)demo
- vue實(shí)現(xiàn)倒計(jì)時(shí)獲取驗(yàn)證碼效果
- vue實(shí)現(xiàn)驗(yàn)證碼按鈕倒計(jì)時(shí)功能
- vue中多個(gè)倒計(jì)時(shí)實(shí)現(xiàn)代碼實(shí)例
- vue實(shí)現(xiàn)列表倒計(jì)時(shí)
相關(guān)文章
使用Vite搭建vue3+TS項(xiàng)目的實(shí)現(xiàn)步驟
本文主要介紹了使用Vite搭建vue3+TS項(xiàng)目的實(shí)現(xiàn)步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-01-01vue2老項(xiàng)目中node-sass更換dart-sass的操作方法
這篇文章主要介紹了vue2老項(xiàng)目中node-sass更換dart-sass的操作方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2024-07-07vue請(qǐng)求函數(shù)和路由的安裝使用過(guò)程
這篇文章主要介紹了vue請(qǐng)求函數(shù)和路由的安裝使用過(guò)程,本文給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧2024-08-08Vue高性能列表GridList組件及實(shí)現(xiàn)思路詳解
這篇文章主要為大家介紹了Vue高性能列表GridList組件及實(shí)現(xiàn)思路詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-11-11詳解Vue項(xiàng)目中實(shí)現(xiàn)錨點(diǎn)定位
這篇文章主要介紹了Vue項(xiàng)目中實(shí)現(xiàn)錨點(diǎn)定位,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04Vue+elementui 實(shí)現(xiàn)復(fù)雜表頭和動(dòng)態(tài)增加列的二維表格功能
這篇文章主要介紹了Vue+elementui 實(shí)現(xiàn)復(fù)雜表頭和動(dòng)態(tài)增加列的二維表格功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-09-09Vue自定義指令實(shí)現(xiàn)卡片翻轉(zhuǎn)功能
這篇文章主要給大家介紹了Vue自定義指令實(shí)現(xiàn)卡片翻轉(zhuǎn)功能的代碼示例,文章通過(guò)代碼示例講解的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作有一定的參幫助,需要的朋友可以參考下2023-11-11