fix(components): [el-table] avoid scrollbar not display (#5920)

* fix(components): [el-table] avoid scrollbar not display

* chore: optimize code
This commit is contained in:
msidolphin 2022-02-11 15:17:34 +08:00 committed by GitHub
parent dcb7365365
commit 43c41015eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -115,7 +115,6 @@ export default defineComponent({
const update = () => { const update = () => {
if (!wrap$.value) return if (!wrap$.value) return
const offsetHeight = wrap$.value.offsetHeight - GAP const offsetHeight = wrap$.value.offsetHeight - GAP
const offsetWidth = wrap$.value.offsetWidth - GAP const offsetWidth = wrap$.value.offsetWidth - GAP
@ -151,6 +150,19 @@ export default defineComponent({
{ immediate: true } { immediate: true }
) )
watch(
() => [props.maxHeight, props.height],
() => {
if (!props.native)
nextTick(() => {
update()
if (wrap$.value) {
barRef.value?.handleScroll(wrap$.value)
}
})
}
)
provide( provide(
scrollbarContextKey, scrollbarContextKey,
reactive({ reactive({

View File

@ -137,12 +137,17 @@ class TableLayout<T> {
updateElsHeight() { updateElsHeight() {
if (!this.table.$ready) return nextTick(() => this.updateElsHeight()) if (!this.table.$ready) return nextTick(() => this.updateElsHeight())
const { const {
tableWrapper,
headerWrapper, headerWrapper,
appendWrapper, appendWrapper,
footerWrapper, footerWrapper,
tableHeader, tableHeader,
tableBody, tableBody,
} = this.table.refs } = this.table.refs
if (tableWrapper && tableWrapper.style.display === 'none') {
// avoid v-show
return
}
this.appendHeight.value = appendWrapper ? appendWrapper.offsetHeight : 0 this.appendHeight.value = appendWrapper ? appendWrapper.offsetHeight : 0
if (this.showHeader && !headerWrapper) return if (this.showHeader && !headerWrapper) return
const headerTrElm: HTMLElement = tableHeader ? tableHeader : null const headerTrElm: HTMLElement = tableHeader ? tableHeader : null