liuqiao 1 rok temu
rodzic
commit
6493828de3
3 zmienionych plików z 24 dodań i 1 usunięć
  1. 11 1
      src/components/layout/NavigateBar.vue
  2. 12 0
      src/js/lindex.js
  3. 1 0
      src/main.js

+ 11 - 1
src/components/layout/NavigateBar.vue

@@ -49,15 +49,25 @@
 </template>
 
 <script setup>
-import { computed,ref } from "vue";
+import { computed,ref,onMounted } from "vue";
 import { useStore } from "vuex";
 import logo from "@/assets/logo.png";
+import {timestampToTime} from '@/js/lindex.js'
+
 const title = "灾情推演软件";
 const activeIndex = ref('1')
 const activeIndex2 = ref('1')
 const handleSelect = (key,keyPath) => {
   console.log(key, keyPath)
 }
+
+onMounted(() => {
+    
+const timestamp = new Date().getTime();
+console.log(timestamp);
+    timestampToTime(1709199092000)
+});
+
 </script>
 <style lang="scss" scoped>
 .ve_menu_logo {

+ 12 - 0
src/js/lindex.js

@@ -0,0 +1,12 @@
+export function timestampToTime(timestamp) {
+        let date = new Date(timestamp);
+        let year = date.getFullYear();
+        let month = ("0" + (date.getMonth() + 1)).slice(-2);
+        let day = ("0" + date.getDate()).slice(-2);
+        let hour = ("0" + date.getHours()).slice(-2);
+        let minute = ("0" + date.getMinutes()).slice(-2);
+        let second = ("0" + date.getSeconds()).slice(-2);
+        let formattedTime = year + "/" + month + "/" + day + " " + hour + ":" + minute + ":" + second;
+        console.log(formattedTime)
+        return formattedTime;
+     }

+ 1 - 0
src/main.js

@@ -9,6 +9,7 @@ import ElementUI from 'element-plus'
 import { createPinia } from 'pinia'
 import 'element-plus/theme-chalk/index.css' // 引入整个Element样式
 import "normalize.css/normalize.css";//重置样式
+import '@/js/lindex.js'
 
 //import '"element-plus/dist/index.css'
 //创建一个路由.user(router)