计算当前页面最大表格高度
parent
a1c9ae38b1
commit
e92549a72b
@ -0,0 +1,43 @@
|
|||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
tableHeight: 100
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
calculateHeight() {
|
||||||
|
let conditionHeight = 0
|
||||||
|
if (this.pageHeaderRef && this.pageHeaderRef.offsetHeight) {
|
||||||
|
conditionHeight = this.pageHeaderRef.offsetHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const remainingHeight = window.innerHeight - this.fixedHeight - conditionHeight
|
||||||
|
this.tableHeight = Math.max(remainingHeight, this.minHeight)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.calculateHeight()
|
||||||
|
window.addEventListener('resize', this.calculateHeight)
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
window.removeEventListener('resize', this.calculateHeight)
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
pageHeaderRef: {
|
||||||
|
type: HTMLElement,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
fixedHeight: {
|
||||||
|
type: Number,
|
||||||
|
default: 200
|
||||||
|
},
|
||||||
|
minHeight: {
|
||||||
|
type: Number,
|
||||||
|
default: 350
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue