this
.
dom
=
this
.
$refs
.
table
.
bodyWrapper
this
.
dom
.
addEventListener
(
'scroll'
,
(
)
=>
{
let
scrollTop
=
this
.
dom
.
scrollTop
let
scrollHeight
=
this
.
dom
.
scrollHeight
let
clientHeight
=
this
.
dom
.
clientHeight
let
scrollBottom
=
scrollHeight
-
scrollTop
-
clientHeight
if
(
scrollBottom
<
1
)
{
if
(
this
.
workforceTemDataAll
.
length
<=
this
.
workforceTemDataCurrect
.
length
)
return
this
.
loading
=
true
if
(
this
.
workforceTemDataCurrect
.
length
+
10
>
this
.
workforceTemDataAll
.
length
)
{
this
.
dom
.
scrollTop
=
this
.
dom
.
scrollTop
-
30
this
.
workforceTemDataCurrect
.
push
(
...
this
.
workforceTemDataAll
)
}
else
{
this
.
dom
.
scrollTop
=
this
.
dom
.
scrollTop
-
30
let
id
=
this
.
workforceTemDataCurrect
.
length
for
(
let
index
=
id
-
1
;
index
<=
id
+
9
;
index
++
)
{
this
.
workforceTemDataCurrect
.
push
(
this
.
workforceTemDataAll
[
index
]
)
setTimeout
(
(
)
=>
{
this
.
loading
=
false
}
,
500
)
注意在子组件中调用时要使用$nextTick函数
.my-
table
.el-
table
__fixed-body-wrapper {
overflow: auto;
max-height: 200px; /* 根据实际情况设置 */
其中,`.my-
table
` 是你在第一步中添加的 `class`,`max-height` 是设置
滚动
条区域的最大高度。如果你的表格高度不确定,可以使用 `max-height: calc(100vh - Xpx);`,其中 `X` 为除表格外其他元素高度之和。
如果你的表格存在固定列,请同时添加第二个样式。
如果你的表格存在
分页
,请注意将
滚动
条样式应用于
分页
后的表格。
如果你的表格存在合并行或列,请注意计算表格高度时将合并单元格展开。
以上操作应该能够解决你的问题。如果还有疑问,请随时问我。
时雨乍停: