From 23e86bcf1aa407d777d5d182e37889ab2acd74ae Mon Sep 17 00:00:00 2001 From: Leopoldthecoder Date: Fri, 17 Nov 2017 12:22:55 +0800 Subject: [PATCH] Table: fix high CPU consumption --- examples/docs/en-US/table.md | 1 + examples/docs/zh-CN/table.md | 1 + packages/table/src/table.vue | 11 +---------- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/examples/docs/en-US/table.md b/examples/docs/en-US/table.md index b2bfd2031..24ad83e43 100644 --- a/examples/docs/en-US/table.md +++ b/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 | diff --git a/examples/docs/zh-CN/table.md b/examples/docs/zh-CN/table.md index b80120ecd..8e08b640c 100644 --- a/examples/docs/zh-CN/table.md +++ b/examples/docs/zh-CN/table.md @@ -2053,6 +2053,7 @@ | setCurrentRow | 用于单选表格,设定某一行为选中行,如果调用时不加参数,则会取消目前高亮行的选中状态。 | row | | clearSort | 用于清空排序条件,数据会恢复成未排序的状态 | — | | clearFilter | 用于清空过滤条件,数据会恢复成未过滤的状态 | — | +| doLayout | 对 Table 进行重新布局。当 Table 或其祖先元素由隐藏切换为显示时,可能需要调用此方法 | — | ### Table Slot | name | 说明 | diff --git a/packages/table/src/table.vue b/packages/table/src/table.vue index d85b8c278..cd528e31e 100644 --- a/packages/table/src/table.vue +++ b/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' }; } };