diff --git a/src/components/table/table.vue b/src/components/table/table.vue index 3957b68..96ef55a 100644 --- a/src/components/table/table.vue +++ b/src/components/table/table.vue @@ -23,12 +23,12 @@ :obj-data="objData">
- @@ -188,6 +188,7 @@ currentContext: this.context, cloneData: deepCopy(this.data), // when Cell has a button to delete row data, clickCurrentRow will throw an error, so clone a data showVerticalScrollBar:false, + headerWidth:0 }; }, computed: { @@ -253,7 +254,7 @@ if (this.bodyHeight > this.bodyRealHeight) { width = this.tableWidth; } else { - width = this.tableWidth - this.scrollBarWidth; + width = this.tableWidth - (this.showVerticalScrollBar?this.scrollBarWidth:0); } } // const width = this.bodyHeight === 0 ? this.tableWidth : this.tableWidth - this.scrollBarWidth; @@ -348,7 +349,12 @@ this.tableWidth = parseInt(getStyle(this.$el, 'width')) - 1; } this.columnsWidth = {}; - if (!this.$refs.tbody) return; + this.fixedHeader(); + this.headerWidth = this.$refs.header.childNodes[0].offsetWidth; + if (!this.$refs.tbody) { + this.showVerticalScrollBar = false; + return; + } this.$nextTick(() => { let columnsWidth = {}; let autoWidthIndex = -1; @@ -358,7 +364,6 @@ const $tr = this.$refs.tbody.$el.querySelectorAll('tbody tr'); if ($tr.length === 0) return; const $td = $tr[0].children; - for (let i = 0; i < $td.length; i++) { // can not use forEach in Firefox const column = this.cloneColumns[i]; @@ -375,7 +380,6 @@ }; } this.columnsWidth = columnsWidth; - this.fixedHeader(); if (this.$refs.tbody) { let bodyContentEl = this.$refs.tbody.$el; diff --git a/src/styles/components/table.less b/src/styles/components/table.less index 725f0a7..5d49228 100644 --- a/src/styles/components/table.less +++ b/src/styles/components/table.less @@ -74,6 +74,11 @@ overflow: auto; //position: relative; } + &-tip{ + overflow-x: auto; + overflow-y: hidden; + //position: relative; + } &-with-fixed-top&-with-footer{ .@{table-prefix-cls}-footer{ -- libgit2 0.21.4
+