在开发中,需要表格控件根据浏览器高度进行调整,固定表头,且然后多余的出滚动条,官方给出的:
只要在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>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
网友评论