就直接贴代码了
里边用了vue的v-for循环数据可以忽略不计,主要是css样式*
<table border="1" cellspacing="0" cellpadding="0" class="kcdata" height="500px">
<thead>
<tr>
<th>序号</th>
<th>名称</th>
<th>库存</th>
</tr>
</thead>
<tbody :style="{height:(h-200)+'px'}">//给tbody固定高
<tr v-for="(i,index) in 100" :key="index" class="cptr">
<td style="text-align:center">{{index+1}}</td>
<td style="text-align:center">12345</td>
<td style="text-align:center">12</td>
</tr>
</tbody>
</table>
<style>
//内容滚动
table tbody {
display: block;
overflow-y: scroll;
}
//固定表头
table thead,
tbody tr {
display: table;
width: 100%;
table-layout: fixed;
}
</style>