如何在 NativeScript 中使用倒数计时器?
How to use Countdown Timer in NativeScript?
如何在 NativeScript 中使用日期格式实现倒数计时器?
setInterval(() => {
}, 1000);
getRemainingTime(remainingMillis) {
setInterval(() => {
let seconds = Math.floor(remainingMillis / 1000);
let minute = Math.floor(seconds / 60);
seconds = seconds % 60;
let hour = Math.floor(minute / 60);
minute = minute % 60;
const day = Math.floor(hour / 24);
hour = hour % 24;
let remainTime
if (day > 0) {
remainTime = day + "d:" + hour + "h:" + minute + "m:" + seconds + "s";
} else {
remainTime = hour + "h:" + minute + "m:" + seconds + "s";
}
remainingMillis = remainingMillis - 1000;
console.log(remainTime);
}, 1000);
}
如何在 NativeScript 中使用日期格式实现倒数计时器?
setInterval(() => {
}, 1000);
getRemainingTime(remainingMillis) {
setInterval(() => {
let seconds = Math.floor(remainingMillis / 1000);
let minute = Math.floor(seconds / 60);
seconds = seconds % 60;
let hour = Math.floor(minute / 60);
minute = minute % 60;
const day = Math.floor(hour / 24);
hour = hour % 24;
let remainTime
if (day > 0) {
remainTime = day + "d:" + hour + "h:" + minute + "m:" + seconds + "s";
} else {
remainTime = hour + "h:" + minute + "m:" + seconds + "s";
}
remainingMillis = remainingMillis - 1000;
console.log(remainTime);
}, 1000);
}