<el-table
      ref="tableRef"
      :data="tableData"
      stripe
      border
      :height="tableHeight"
      highlight-current-row
      @row-click="rowClick"
    >
// table元素
const tableRef = ref(null);
// table高度
const tableHeight = ref();

onMounted(() => {
  // 设置表格初始高度为innerHeight-offsetTop-表格底部与浏览器底部距离85
  tableHeight.value = window.innerHeight - tableRef.value.$el.offsetTop - 85;
  // 监听浏览器高度变化
  window.onresize = () => {
    tableHeight.value = window.innerHeight - tableRef.value.$el.offsetTop - 85;
  };
});

Logo

前往低代码交流专区

更多推荐