This commit is contained in:
huanghong 2018-03-17 02:29:30 +08:00
parent 14d1de0573
commit f25f12527e
3 changed files with 14 additions and 14 deletions

View file

@ -27,7 +27,7 @@ export default {
// when browser has scrollBar,set a width to resolve scroll position bug // when browser has scrollBar,set a width to resolve scroll position bug
if (width && this.columns.length === index + 1 && top && this.$parent.bodyHeight !== 0) { if (width && this.columns.length === index + 1 && top && this.$parent.bodyHeight !== 0) {
let scrollBarWidth = this.$parent.scrollBarWidth; let scrollBarWidth = this.$parent.scrollBarWidth;
if (!this.$parent.showScrollBar) scrollBarWidth = 0; if (!this.$parent.showVerticalScrollBar) scrollBarWidth = 0;
width += scrollBarWidth; width += scrollBarWidth;
} }
// when fixed type,reset first right fixed column's width // when fixed type,reset first right fixed column's width
@ -35,7 +35,7 @@ export default {
const firstFixedIndex = this.columns.findIndex((col) => col.fixed === 'right'); const firstFixedIndex = this.columns.findIndex((col) => col.fixed === 'right');
if (firstFixedIndex === index) { if (firstFixedIndex === index) {
let scrollBarWidth = this.$parent.scrollBarWidth; let scrollBarWidth = this.$parent.scrollBarWidth;
if (!this.$parent.showScrollBar) scrollBarWidth = 0; if (!this.$parent.showVerticalScrollBar) scrollBarWidth = 0;
width += scrollBarWidth; width += scrollBarWidth;
} }
} }

View file

@ -86,7 +86,7 @@
styles () { styles () {
const style = Object.assign({}, this.styleObject); const style = Object.assign({}, this.styleObject);
let scrollBarWidth = this.$parent.scrollBarWidth; let scrollBarWidth = this.$parent.scrollBarWidth;
if(!this.$parent.showScrollBar) scrollBarWidth = 0; if(!this.$parent.showVerticalScrollBar) scrollBarWidth = 0;
const width = this.$parent.bodyHeight === 0 ? parseInt(this.styleObject.width) : parseInt(this.styleObject.width) + scrollBarWidth; const width = this.$parent.bodyHeight === 0 ? parseInt(this.styleObject.width) : parseInt(this.styleObject.width) + scrollBarWidth;
style.width = `${width}px`; style.width = `${width}px`;
return style; return style;

View file

@ -187,7 +187,7 @@
scrollBarWidth: getScrollBarSize(), scrollBarWidth: getScrollBarSize(),
currentContext: this.context, 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 cloneData: deepCopy(this.data), // when Cell has a button to delete row data, clickCurrentRow will throw an error, so clone a data
showScrollBar:false, showVerticalScrollBar:false,
}; };
}, },
computed: { computed: {
@ -378,20 +378,20 @@
this.fixedHeader(); this.fixedHeader();
if (this.$refs.tbody) { if (this.$refs.tbody) {
let bodyContent = this.$refs.tbody.$el; let bodyContentEl = this.$refs.tbody.$el;
let className = bodyContent.parentElement.className; let bodyEl = bodyContentEl.parentElement;
bodyContent.parentElement.className = ''; let className = bodyEl.className;
let bodyContentHeight = bodyContent.offsetHeight; bodyEl.className = '';
let bodyContentWidth = bodyContent.offsetWidth; let bodyContentHeight = bodyContentEl.offsetHeight;
bodyContent.parentElement.className = className; let bodyContentWidth = bodyContentEl.offsetWidth;
let bodyWidth = this.$refs.tbody.$el.parentElement.offsetWidth; bodyEl.className = className;
let bodyHeight = this.$refs.tbody.$el.parentElement.offsetHeight; let bodyWidth = bodyEl.offsetWidth;
let bodyHeight = bodyEl.offsetHeight;
let scrollBarWidth = 0; let scrollBarWidth = 0;
if (bodyWidth < bodyContentWidth) { if (bodyWidth < bodyContentWidth) {
scrollBarWidth = this.scrollBarWidth; scrollBarWidth = this.scrollBarWidth;
} }
let show = this.bodyHeight? bodyHeight - scrollBarWidth < bodyContentHeight : false; this.showVerticalScrollBar = this.bodyHeight? bodyHeight - scrollBarWidth < bodyContentHeight : false;
this.showScrollBar = show;
} }
} }
}); });