Commit 04ad1060 authored by leon's avatar leon

fix: realTime component add create

parent ecdd5c23
<template> <template>
<view> <view class="timer">
<div class="timer"> <NormalTitle :elementInfo="elementInfo"></NormalTitle>
<NormalTitle :elementInfo="elementInfo"></NormalTitle> <div :style="{
<div :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>
</div> </div>
</view> </view>
</template> </template>
...@@ -25,13 +23,15 @@ ...@@ -25,13 +23,15 @@
realTime: '', realTime: '',
timer: null timer: null
}; };
},
created() {
this.initChart()
}, },
destroyed() {
onUnLoad() {
clearInterval(this.timer) clearInterval(this.timer)
}, },
methods: { methods: {
initChart() { initChart() {
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())
......
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