Commit 324501af authored by Jenny's avatar Jenny

feat: 实时时间

parent 280dfa8c
<template> <template>
<view> <view class="timer">
<div class="timer">
<NormalTitle :elementInfo="elementInfo"></NormalTitle> <NormalTitle :elementInfo="elementInfo"></NormalTitle>
<div :style="{ <view :style="{
'font-size':`${elementInfo.option.time.textStyle.fontSize}px`, 'font-size':`${elementInfo.option.time.textStyle.fontSize}px`,
'color': elementInfo.option.time.textStyle.color, 'color': elementInfo.option.time.textStyle.color,
'font-weight': elementInfo.option.time.textStyle.fontWeight, 'font-weight': elementInfo.option.time.textStyle.fontWeight,
'text-align': elementInfo.option.time.left, 'text-align': elementInfo.option.time.left,
}"> }">
{{ realTime }} {{ realTime }}
</div> </view>
</div>
</view> </view>
</template> </template>
...@@ -26,17 +24,21 @@ ...@@ -26,17 +24,21 @@
timer: null timer: null
}; };
}, },
onReady() {
this.getRealTime()
},
onUnLoad() { onUnLoad() {
clearInterval(this.timer) clearInterval(this.timer)
this.timer = null
}, },
methods: { methods: {
initChart() { getRealTime() {
this.timer = setInterval(() => { this.timer = setInterval(() => {
const timestamp = new Date().getTime() const timestamp = new Date().getTime()
this.realTime = this.$u.timeFormat(timestamp, this.getDateFormat()) this.realTime = this.$u.timeFormat(timestamp, this.getDateFormat())
}, 1000) }, 1000)
}, },
initChart() {},
// 大屏报表时间格式和uniapp的不一致,需要转换 // 大屏报表时间格式和uniapp的不一致,需要转换
getDateFormat() { getDateFormat() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment