export default {
name: "HelloWorld",
data() {
return {
endTime: "2020-01-10 19:00:00",
day: "",
hour: "",
min: "",
second: ""
};
},
created() {
this.getReserTime();
},
methods: {
dateFormate(num){
if(num<10){
return '0'+num
}else{
return num
}
},
getReserTime() {
let interval = setInterval(() => {
let nowTime = new Date().getTime();
let endTime = new Date(this.endTime).getTime();
let chaTime = (endTime - nowTime) / 1000;
this.day = parseInt(chaTime / (60 * 60 * 24));
this.hour = parseInt((chaTime % (60 * 60 * 24)) / 3600);
this.min = parseInt(((chaTime % (60 * 60 * 24)) % 3600) / 60);
this.second = parseInt(((chaTime % (60 * 60 * 24)) % 3600) % 60);
}, 1000);
}
}
};
vue倒计时
最新推荐文章于 2022-11-01 20:36:57 发布