From b1262a3d8d0804b3afed70952453a7030494b461 Mon Sep 17 00:00:00 2001 From: huanghong Date: Sat, 31 Mar 2018 19:48:15 +0800 Subject: [PATCH] fixed no data width calculation --- src/components/table/table.vue | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/table/table.vue b/src/components/table/table.vue index ea87beb..6b36ddd 100644 --- a/src/components/table/table.vue +++ b/src/components/table/table.vue @@ -570,9 +570,8 @@ this.headerWidth = this.$refs.header.childNodes[0].offsetWidth; this.headerHeight = this.$refs.header.childNodes[0].offsetHeight; this.showHorizontalScrollBar = this.headerWidth>this.$refs.header.parentElement.offsetWidth; - if (!this.$refs.tbody) { + if (!this.$refs.tbody || !this.data || this.data.length === 0) { this.showVerticalScrollBar = false; - return; } else{ let bodyContentEl = this.$refs.tbody.$el; @@ -592,8 +591,8 @@ }else{ bodyEl.classList.remove(this.prefixCls +'-overflowX'); } - this.tableWidth = this.cloneColumns.map(cell => cell._width).reduce((a, b) => a + b, 0) + (this.showVerticalScrollBar?this.scrollBarWidth:0); } + this.tableWidth = this.cloneColumns.map(cell => cell._width).reduce((a, b) => a + b, 0) + (this.showVerticalScrollBar?this.scrollBarWidth:0); }, hideColumnFilter () { -- libgit2 0.21.4