|
|
@@ -29,14 +29,13 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
- // 格式化时间:毫秒 → 00:00:00.00 格式(毫秒两位)
|
|
|
+ // 格式化时间:00:00:00 格式(不显示毫秒)
|
|
|
formattedTime() {
|
|
|
const elapsed = this.baseMillis + (this.nowTs - this.startTs)
|
|
|
const totalMs = Math.max(0, Math.floor(elapsed))
|
|
|
const hours = String(Math.floor(totalMs / 3600000)).padStart(2, '0')
|
|
|
const minutes = String(Math.floor((totalMs % 3600000) / 60000)).padStart(2, '0')
|
|
|
const seconds = String(Math.floor((totalMs % 60000) / 1000)).padStart(2, '0')
|
|
|
- // const ms2 = String(Math.floor((totalMs % 1000) / 10)).padStart(2, '0')
|
|
|
return `${hours}:${minutes}:${seconds}`
|
|
|
}
|
|
|
},
|
|
|
@@ -84,7 +83,16 @@ export default {
|
|
|
},
|
|
|
// 组件卸载时清理定时器(避免内存泄漏,与 Vue3 一致)
|
|
|
beforeDestroy() {
|
|
|
- if (this._unsub) this._unsub()
|
|
|
+ if (this._unsub) {
|
|
|
+ this._unsub()
|
|
|
+ this._unsub = null
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforeUnmount() {
|
|
|
+ if (this._unsub) {
|
|
|
+ this._unsub()
|
|
|
+ this._unsub = null
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|