소스 검색

1.组件销毁时销毁定时器

GouGengquan 4 달 전
부모
커밋
56ac7de3a9
1개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  1. 15 0
      src/views/assets/workbench/eqpt/calculate/importInfo.vue

+ 15 - 0
src/views/assets/workbench/eqpt/calculate/importInfo.vue

@@ -1276,6 +1276,21 @@ export default {
     this.getEqptDataPage()
     this.getPPI()
   },
+  beforeUnmount () {
+      // 清除定时器
+      if (this.autoSaveTimer) {
+        clearInterval(this.autoSaveTimer);
+        this.autoSaveTimer = null;
+      }
+      if (this.autoSaveImpTimer) {
+        clearInterval(this.autoSaveImpTimer);
+        this.autoSaveImpTimer = null;
+      }
+      if (this.autoSaveNonSTimer) {
+        clearInterval(this.autoSaveNonSTimer);
+        this.autoSaveNonSTimer = null;
+      }
+  },
   methods: {
     startAutoSave() {
       if (this.autoSaveAtive) {