Преглед на файлове

Table: fix high CPU consumption

Leopoldthecoder преди 7 години
родител
ревизия
23e86bcf1a
променени са 3 файла, в които са добавени 3 реда и са изтрити 10 реда
  1. 1 0
      examples/docs/en-US/table.md
  2. 1 0
      examples/docs/zh-CN/table.md
  3. 1 10
      packages/table/src/table.vue

+ 1 - 0
examples/docs/en-US/table.md

@@ -1990,6 +1990,7 @@ You can customize row index in `type=index` columns.
 | setCurrentRow | used in single selection Table, set a certain row selected. If called without any parameter, it will clear selection. | row |
 | clearSort | clear sorting, restore data to the original order | — |
 | clearFilter | clear filter | — |
+| doLayout | Refresh the layout of Table. When the visibility of Table changes, you may need to call this method to get a correct layout | — |
 
 ### Table Slot
 | Name | Description |

+ 1 - 0
examples/docs/zh-CN/table.md

@@ -2053,6 +2053,7 @@
 | setCurrentRow | 用于单选表格,设定某一行为选中行,如果调用时不加参数,则会取消目前高亮行的选中状态。 | row |
 | clearSort | 用于清空排序条件,数据会恢复成未排序的状态 | — |
 | clearFilter | 用于清空过滤条件,数据会恢复成未过滤的状态 | — |
+| doLayout | 对 Table 进行重新布局。当 Table 或其祖先元素由隐藏切换为显示时,可能需要调用此方法 | — |
 
 ### Table Slot
 | name | 说明 |

+ 1 - 10
packages/table/src/table.vue

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