时钟显示中午12点BUG修复

This commit is contained in:
ZtRXR 2023-09-11 22:31:08 +08:00
parent 89433705c5
commit 70af089942

View File

@ -1,5 +1,8 @@
<script setup lang="ts">
const showTime = ref<Date>(new Date())
// const testDate = new Date()
// testDate.setHours(24)
// const showTime = ref<Date>(testDate)
const renewTime = ()=>{
console.log("正在更新时间")
showTime.value = new Date()
@ -19,7 +22,8 @@ onBeforeUnmount(()=>{
<Title>大屏时钟</Title>
<client-only>
<div>
<el-text>{{(showTime.getHours()%12)/10<1?`0${showTime.getHours()%12}`:showTime.getHours()%12}}</el-text>
<!-- <el-text>{{(showTime.getHours()%12)/10<1?`0${showTime.getHours()%12}`:showTime.getHours()%12}}</el-text>-->
<el-text>{{showTime.getHours()>12?(showTime.getHours()%12)/10<1?`0${showTime.getHours()%12}`:showTime.getHours()%12:(showTime.getHours())/10<1?`0${showTime.getHours()}`:showTime.getHours()}}</el-text>
<el-text style="font-size: 5vw" type="primary">{{(showTime.getHours()/12>1?"PM":"AM")}}</el-text>
<el-text>:</el-text>
<el-text>{{(showTime.getMinutes())/10<1?`0${showTime.getMinutes()}`:showTime.getMinutes()}}</el-text>