Parcourir la source

refactor: 将resize和getMaxHeigth移至mounted钩子

yusheng il y a 3 mois
Parent
commit
49ba17df38
1 fichiers modifiés avec 6 ajouts et 8 suppressions
  1. 6 8
      src/views/home/index.vue

+ 6 - 8
src/views/home/index.vue

@@ -474,13 +474,7 @@
         productLineList: []
       };
     },
-    created() {
-      setTimeout(() => {
-        this.$nextTick(() => {
-          this.$refs.barRef.resize();
-        });
-      }, 300);
-    },
+    created() {},
     watch: {
       isFullscreen() {
         setTimeout(() => {
@@ -490,6 +484,10 @@
       }
     },
     mounted() {
+      setTimeout(() => {
+        this.$refs.barRef.resize();
+        this.getMaxHeigth();
+      }, 300);
       getFactoryarea({
         pageNum: 1,
         size: 999,
@@ -502,7 +500,7 @@
       this.timer = setInterval(() => {
         this.init();
       }, 3600000);
-      this.getMaxHeigth();
+
       window.addEventListener('resize', this.getMaxHeigth);
     },
     beforeDestroy() {