vue3 elementplus table表格高度自适应
<el-tableref="tableRef":data="tableData"stripeborder:height="tableHeight"highlight-current-row@row-click="rowClick">// table元素const tableRef = ref(null);// table高度const tableHeight = ref();.
·
<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;
};
});
更多推荐
已为社区贡献4条内容
所有评论(0)