Browse Source

Table: avoid doLayout continuous executing

Leopoldthecoder 7 năm trước cách đây
mục cha
commit
c1155b3be0
1 tập tin đã thay đổi với 5 bổ sung2 xóa
  1. 5 2
      packages/table/src/table.vue

+ 5 - 2
packages/table/src/table.vue

@@ -345,6 +345,7 @@
         this.updateScrollY();
         this.layout.update();
         this.$nextTick(() => {
+          if (this.destroyed) return;
           if (this.height) {
             this.layout.setHeight(this.height);
           } else if (this.maxHeight) {
@@ -355,7 +356,7 @@
           if (this.$el) {
             this.isHidden = this.$el.clientWidth === 0;
             if (this.isHidden && this.layout.bodyWidth) {
-              setTimeout(() => this.doLayout());
+              setTimeout(() => this.debouncedLayout());
             }
           }
         });
@@ -496,6 +497,7 @@
     },
 
     destroyed() {
+      this.destroyed = true;
       if (this.windowResizeListener) removeResizeListener(this.$el, this.windowResizeListener);
     },
 
@@ -536,7 +538,8 @@
         resizeProxyVisible: false,
         // 是否拥有多级表头
         isGroup: false,
-        scrollPosition: 'left'
+        scrollPosition: 'left',
+        destroyed: false
       };
     }
   };