Quellcode durchsuchen

增加时间、标题组件

tongshangming vor 1 Jahr
Ursprung
Commit
9b8cd2f325
2 geänderte Dateien mit 45 neuen und 32 gelöschten Zeilen
  1. 33 0
      components/index.js
  2. 12 32
      index.html

+ 33 - 0
components/index.js

@@ -0,0 +1,33 @@
+Vue.component('fs-time',{
+  template: `<span class="header-time">{{time}}</span>`,
+  data(){
+    return {
+      time: ''
+    }
+  },
+  created() {
+    this.time = dayjs().format('YYYY-MM-DD HH:mm:ss')
+    this.timer = setInterval(() => {
+      this.time = dayjs().format('YYYY-MM-DD HH:mm:ss')
+    }, 1000)
+  },
+  beforeDestroy() {
+    if (this.timer) {
+      clearInterval(this.timer)
+    }
+  }
+})
+
+Vue.component('fs-title',{
+  props: {
+    title: ''
+  },
+  template: `
+  <div class="panel-title">
+    <div class="panel-title-text">{{title}}</div>
+  </div>
+  `,
+  data(){
+    return {}
+  }
+})

+ 12 - 32
index.html

@@ -15,60 +15,47 @@
 	<script src="./js/echarts-tooltip-carousel.js"></script>
 	<script src="./js/tailwind.js"></script>
 	<script src="./js/dayjs.min.js"></script>
+	<script src="./components/index.js"></script>
 </head>
 <body>
   <div id="app">
 		<dv-full-screen-container>
 			<header id="header">
 				<span class="header-title">可视化驾驶舱</span>
-				<span class="header-time">{{time}}</span>
+				<fs-time></fs-time>
 			</header>
 			<div class="main flex w-full">
 				<div class="main-left flex flex-col basis-1/4">
 					<dv-border-box-13>
-						<div class="panel-title">
-							<div class="panel-title-text">标题</div>
-						</div>
+						<fs-title title="标题"></fs-title>
 						<div class="panel-content"></div>
 					</dv-border-box-13>
 					<dv-border-box-13>
-						<div class="panel-title">
-							<div class="panel-title-text">标题</div>
-						</div>
+						<fs-title title="标题"></fs-title>
 						<div class="panel-content"></div>
 					</dv-border-box-13>
 					<dv-border-box-13>
-						<div class="panel-title">
-							<div class="panel-title-text">标题</div>
-						</div>
+						<fs-title title="标题"></fs-title>
 						<div class="panel-content"></div>
 					</dv-border-box-13>
 				</div>
 				<div class="main-center flex flex-col flex-grow basis-2/4">
 					<dv-border-box-13>
-						<div class="panel-title">
-							<div class="panel-title-text">标题</div>
-						</div>
+						<fs-title title="标题"></fs-title>
 						<div class="panel-content"></div>
 					</dv-border-box-13>
 				</div>
 				<div class="main-right flex flex-col basis-1/4">
 					<dv-border-box-13>
-						<div class="panel-title">
-							<div class="panel-title-text">标题</div>
-						</div>
+						<fs-title title="标题"></fs-title>
 						<div class="panel-content"></div>
 					</dv-border-box-13>
 					<dv-border-box-13>
-						<div class="panel-title">
-							<div class="panel-title-text">标题</div>
-						</div>
+						<fs-title title="标题"></fs-title>
 						<div class="panel-content"></div>
 					</dv-border-box-13>
 					<dv-border-box-13>
-						<div class="panel-title">
-							<div class="panel-title-text">标题</div>
-						</div>
+						<fs-title title="标题"></fs-title>
 						<div class="panel-content"></div>
 					</dv-border-box-13>
 				</div>
@@ -79,23 +66,16 @@
 
 <script>
 	Vue.component('v-chart', VueECharts)
+
 	const app = new Vue({
 		el: '#app',
     data() { 
 			return {
-				time: '',
+				
 			}
 		},
 		created() {
-			this.time = dayjs().format('YYYY-MM-DD HH:mm:ss')
-			this.timer = setInterval(() => {
-				this.time = dayjs().format('YYYY-MM-DD HH:mm:ss')
-			}, 1000)
-		},
-		beforeDestroy() {
-			if (this.timer) {
-				clearInterval(this.timer)
-			}
+			
 		},
 		mounted() {