在开发中,需要表格控件根据浏览器高度进行调整,固定表头,且然后多余的出滚动条,官方给出的:
只要在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>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
继续阅读与本文标签相同的文章
-
阿里云创新中心蔡素卿:双创是阿里发展生态业务的有力抓手
2026-05-19栏目: 教程
-
通过命令行参数发送阿里云短信 - python
2026-05-19栏目: 教程
-
阿里IOT智能人居邢超:开放阿里生态,助力消费级物联网产业全链路升级
2026-05-19栏目: 教程
-
Cassandra监控运维介绍
2026-05-19栏目: 教程
-
C#读写Excel
2026-05-19栏目: 教程
