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 {
//活動已結(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í)功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!
- vue+vant實(shí)現(xiàn)商品列表批量倒計(jì)時(shí)功能
- Vue寫一個簡單的倒計(jì)時(shí)按鈕功能
- 簡單實(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中多個倒計(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)步驟,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-01-01
vue2老項(xiàng)目中node-sass更換dart-sass的操作方法
這篇文章主要介紹了vue2老項(xiàng)目中node-sass更換dart-sass的操作方法,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2024-07-07
Vue高性能列表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)定位,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04
Vue+elementui 實(shí)現(xiàn)復(fù)雜表頭和動態(tài)增加列的二維表格功能
這篇文章主要介紹了Vue+elementui 實(shí)現(xiàn)復(fù)雜表頭和動態(tài)增加列的二維表格功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-09-09
Vue自定義指令實(shí)現(xiàn)卡片翻轉(zhuǎn)功能
這篇文章主要給大家介紹了Vue自定義指令實(shí)現(xiàn)卡片翻轉(zhuǎn)功能的代碼示例,文章通過代碼示例講解的非常詳細(xì),對大家的學(xué)習(xí)或工作有一定的參幫助,需要的朋友可以參考下2023-11-11

