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

View File

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