瀏覽代碼

fix: echart not render in production

xiaoxian521 4 年之前
父節點
當前提交
68330026b6
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      src/views/welcome.vue

+ 7 - 1
src/views/welcome.vue

@@ -31,7 +31,7 @@ import flop from "../components/flop/index.vue";
 import { ref, computed, onMounted, inject, nextTick } from "vue";
 import { deviceDetection } from "../utils/deviceDetection";
 import { echartsJson } from "../api/mock";
-import { useEventListener } from "@vueuse/core";
+import { useEventListener, tryOnUnmounted } from "@vueuse/core";
 
 let brokenLine: any = null; //折线图实例
 export default {
@@ -188,6 +188,12 @@ export default {
       });
     });
 
+    tryOnUnmounted(() => {
+      if (!brokenLine) return;
+      brokenLine.dispose();
+      brokenLine = null;
+    });
+
     return {
       greetings,
       mobile,