在開發中,需要表格控件根據瀏覽器高度進行調整,固定表頭,且然后多余的出滾動條,官方給出的:
只要在el-table元素中定義了height屬性,即可實現固定表頭的表格,而不需要額外的代碼。
然后直接上template代碼:
<template> <el-table :data="tableData3" height="250" border style="width: 100%"> <el-table-column prop="date" label="日期" width="180"> </el-table-column> </el-table></template>
其中height="250"是固定值,我們可以在data中設置一個tableHeight,其中x是根據你布局自己算出來的值,也可以換成動態監測的值,就是父級到body的值,這個可以自行添加
data(){ return{ tableHeight: window.innerHeight - x }}
template中:
<template> <el-table :data="tableData3" :height="tableHeight" border style="width: 100%"> <el-table-column prop="date" label="日期" width="180"> </el-table-column> </el-table></template>
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VeVb武林網。
新聞熱點
疑難解答