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)

Logo

前往低代码交流专区

更多推荐