Skip to content

Commit 4a1c057

Browse files
committed
fix: fix the "finish" event of statistic countdown
1 parent e63f9ea commit 4a1c057

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

components/statistic/Countdown.jsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,21 @@ export default {
4747
startTimer() {
4848
if (this.countdownId) return;
4949
this.countdownId = window.setInterval(() => {
50+
const { value } = this.$props;
51+
const timestamp = getTime(value);
52+
53+
if (timestamp < Date.now()) {
54+
this.stopTimer();
55+
}
5056
this.$refs.statistic.$forceUpdate();
5157
}, REFRESH_INTERVAL);
5258
},
5359

5460
stopTimer() {
55-
const { value } = this.$props;
5661
if (this.countdownId) {
5762
clearInterval(this.countdownId);
5863
this.countdownId = undefined;
59-
60-
const timestamp = getTime(value);
61-
if (timestamp < Date.now()) {
62-
this.$emit('finish');
63-
}
64+
this.$emit('finish');
6465
}
6566
},
6667

0 commit comments

Comments
 (0)