Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
ec-report-refactor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lihuizhen
ec-report-refactor
Commits
e52d8092
Commit
e52d8092
authored
Jan 20, 2022
by
peco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat : 实时时间显示
parent
1426785a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
26 deletions
+26
-26
RealTime.vue
components/RealTime/RealTime.vue
+10
-24
common.js
utils/common.js
+16
-2
No files found.
components/RealTime/RealTime.vue
View file @
e52d8092
...
...
@@ -27,39 +27,25 @@ export default {
data
()
{
return
{
realTime
:
''
,
timer
:
null
};
},
onReady
()
{
},
onUnLoad
()
{
clearInterval
(
this
.
timer
)
},
components
:
{
uniEcCanvas
},
methods
:
{
initChart
()
{
const
refreshTime
=
()
=>
{
timer
.
value
=
setInterval
(()
=>
{
realTime
.
value
=
dateFormat
(
new
Date
(),
props
.
elementInfo
.
option
.
dateFormart
)
},
1000
)
}
onMounted
(()
=>
{
refreshTime
()
})
onUnmounted
(()
=>
{
clearInterval
(
timer
.
value
)
timer
.
value
=
null
})
return
{
realTime
,
}
}
initChart
()
{
this
.
timer
=
setInterval
(()
=>
{
this
.
realTime
=
this
.
$u
.
common
.
dateFormat
()
},
1000
)
},
}
}
</
script
>
...
...
utils/common.js
View file @
e52d8092
...
...
@@ -30,11 +30,25 @@ const install = (Vue, vm) => {
}
return
result
}
const
dateFormat
=
()
=>
{
let
date
=
new
Date
();
let
year
=
date
.
getFullYear
();
// 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
let
month
=
date
.
getMonth
()
+
1
<
10
?
"0"
+
(
date
.
getMonth
()
+
1
)
:
date
.
getMonth
()
+
1
;
let
day
=
date
.
getDate
()
<
10
?
"0"
+
date
.
getDate
()
:
date
.
getDate
();
let
hours
=
date
.
getHours
()
<
10
?
"0"
+
date
.
getHours
()
:
date
.
getHours
();
let
minutes
=
date
.
getMinutes
()
<
10
?
"0"
+
date
.
getMinutes
()
:
date
.
getMinutes
();
let
seconds
=
date
.
getSeconds
()
<
10
?
"0"
+
date
.
getSeconds
()
:
date
.
getSeconds
();
// 拼接
return
year
+
"-"
+
month
+
"-"
+
day
+
" "
+
hours
+
":"
+
minutes
+
":"
+
seconds
;
// return year + "-" + month + "-" + day;
}
vm
.
$u
.
common
=
{
converFunction
,
fillDigit
,
toThousands
toThousands
,
dateFormat
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment