From 0f983a5c5add73148e146eb4f63886dc8ab17c90 Mon Sep 17 00:00:00 2001 From: huanghong Date: Mon, 16 Apr 2018 21:26:54 +0800 Subject: [PATCH] update table columns width compute --- examples/routers/table.vue | 15 ++++++++------- src/components/table/table.vue | 14 ++++++++------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/examples/routers/table.vue b/examples/routers/table.vue index 570734f..3e5d233 100644 --- a/examples/routers/table.vue +++ b/examples/routers/table.vue @@ -57,8 +57,9 @@
-
-
+ + +
@@ -462,8 +463,8 @@ title: 'Date', key: 'date', sortable: true, - minWidth:100, - maxWidth:200, + minWidth:80, + maxWidth:150, }, { title: 'Name', @@ -474,14 +475,14 @@ { title: 'Age', key: 'age', - minWidth:100, - maxWidth:200, + minWidth:60, + maxWidth:100, }, { title: 'Address', key: 'address', minWidth:200, - maxWidth:300, + //maxWidth:300, } ], } diff --git a/src/components/table/table.vue b/src/components/table/table.vue index 38cbece..3a4be91 100644 --- a/src/components/table/table.vue +++ b/src/components/table/table.vue @@ -367,6 +367,7 @@ let unUsableWidth = hasWidthColumns.map(cell => cell.width).reduce((a, b) => a + b, 0); + console.log(tableWidth); let usableWidth = tableWidth - unUsableWidth - (this.showVerticalScrollBar?this.scrollBarWidth:0); let usableLength = noWidthColumns.length; let columnWidth = 0; @@ -425,13 +426,13 @@ if (column._width) { width = column._width; } - else if (column.minWidth > width){ - width = column.minWidth; - } - else if (column.maxWidth < width){ - width = column.maxWidth; - } else { + if (column.minWidth > width){ + width = column.minWidth; + } + else if (column.maxWidth < width){ + width = column.maxWidth; + } if (usableWidth>0) { if (usableLength > 1) { usableLength--; @@ -457,6 +458,7 @@ } //this.tableWidth = this.cloneColumns.map(cell => cell._width).reduce((a, b) => a + b, 0); this.tableWidth = this.cloneColumns.map(cell => cell._width).reduce((a, b) => a + b, 0) + (this.showVerticalScrollBar?this.scrollBarWidth:0); + console.log(this.tableWidth); this.columnsWidth = columnsWidth; this.fixedHeader(); }, -- libgit2 0.21.4