Commit 49ed5b0732f89b01cadf798cf140ed5a86585236

Authored by liuqimichale
1 parent 414b2840

headertime

index.html
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <meta name="viewport" content="width=device-width,initial-scale=1.0"> 5 <meta name="viewport" content="width=device-width,initial-scale=1.0">
6 <title>兰州沙盘</title> 6 <title>兰州沙盘</title>
7 <link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico"> 7 <link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico">
8 - <link rel="stylesheet" href="src/style/reset.css" > 8 + <link href="src/style/reset.css" rel="stylesheet" type="text/css" />
9 <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=cuMSxNl5LOY6sf1M3nDGtG6tGXl5a0Bb"></script> 9 <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=cuMSxNl5LOY6sf1M3nDGtG6tGXl5a0Bb"></script>
10 </head> 10 </head>
11 <body> 11 <body>
src/components/VHeader.vue
1 <template> 1 <template>
2 <header class="header-wrap"> 2 <header class="header-wrap">
3 <span>车场实时概况</span> 3 <span>车场实时概况</span>
  4 + <div class="header-time">{{headerTime}}</div>
4 </header> 5 </header>
5 </template> 6 </template>
6 7
7 <script> 8 <script>
  9 +import { formateTime } from "../utils/formate";
  10 +
8 export default { 11 export default {
9 name: 'VHeader', 12 name: 'VHeader',
10 - 13 + data() {
  14 + return {
  15 + headerTime: formateTime()
  16 + }
  17 + }
11 } 18 }
12 </script> 19 </script>
13 20
14 -<style scoped> 21 +<style scoped lang="scss">
15 header { 22 header {
16 height: 65px; 23 height: 65px;
17 - line-height: 65px;  
18 text-align: center; 24 text-align: center;
19 - font-size: 32px; 25 + position: relative;
20 background-image: url("../images/header/headerbg.png"); 26 background-image: url("../images/header/headerbg.png");
21 background-repeat: no-repeat; 27 background-repeat: no-repeat;
22 background-position: center center; 28 background-position: center center;
23 - 29 + >span{
  30 + font-size: 32px;
  31 + line-height: 75px;
  32 + }
  33 + .header-time{
  34 + width: 128px;
  35 + height: 35px;
  36 + line-height: 18px;
  37 + position: absolute;
  38 + right: 10px;
  39 + top:16px;
  40 + padding-left: 45px;
  41 + text-align: left;
  42 + background:url("../images/header/headertime.png") no-repeat 0 center;
  43 + background-size: 35px 35px;
  44 + }
24 } 45 }
25 </style> 46 </style>
src/images/header/headertime.png 0 → 100644

3.25 KB

src/utils/formate.js 0 → 100644
  1 +function formateTime() {
  2 + let date = new Date()
  3 + let str = ''
  4 + let year = date.getFullYear()
  5 + let month = date.getMonth()+1<10? "0"+ (date.getMonth()+1) : date.getMonth()+1
  6 + let day = date.getDate()<10 ? "0"+date.getDate() : date.getDate
  7 + let hours = date.getHours()<10? "0"+date.getHours() : date.getHours()
  8 + let minutes=date.getMinutes()<10 ? "0"+date.getMinutes() : date.getMinutes();
  9 + let seconds=date.getSeconds()<10 ? "0"+date.getSeconds() : date.getSeconds();
  10 +
  11 + str = year +"-"+ month +"-"+day +hours+":"+minutes+":"+seconds
  12 + return str
  13 +}
  14 +
  15 +export { formateTime }