vue3 elementplus table 高度自适应 的两种方法
ref="tables"const tables=ref()const tableHeight=ref()//引入 onMountedonMounted(() => {tableHeight.value = window.innerHeight - tables.value.$el.offsetTop - 100window.onresize = function() {tableHeigh
·
ref="tables"
const tables=ref()
const tableHeight=ref()
//引入 onMounted
onMounted(() => {
tableHeight.value = window.innerHeight - tables.value.$el.offsetTop - 100
window.onresize = function() {
tableHeight.value = window.innerHeight - tables.value.$el.offsetTop - 100
}
})
table height属性给值后表头固定 中间可以滑动
使用上述方法请注意 onresize 方法只能生效一个 兄弟组件都用的话只会生效一个
建议还是用 vh 减去已占用的高度 calc(100vh-xxPX)
更多推荐
已为社区贡献12条内容
所有评论(0)