chore: 滚动到底部的判断

This commit is contained in:
dap 2024-11-21 17:02:22 +08:00
parent f32a949482
commit 012808a1da

View File

@ -1,4 +1,6 @@
<script setup lang="ts">
import { useTemplateRef } from 'vue';
import { Page } from '@vben/common-ui';
import {
@ -11,15 +13,35 @@ import {
Tabs,
Tag,
} from 'ant-design-vue';
import { debounce } from 'lodash-es';
import { ApprovalCard } from '../components';
const scrollContainer = useTemplateRef('scrollContainer');
const handleScroll = debounce((e: Event) => {
if (!e.target) {
return;
}
// e.target.scrollTop
// e.target.clientHeight
// e.target.scrollHeight
const { scrollTop, clientHeight, scrollHeight } = e.target as HTMLElement;
//
const isBottom = scrollTop + clientHeight >= scrollHeight;
console.log(isBottom);
// console.log(scrollTop + clientHeight);
// console.log(scrollHeight);
}, 200);
</script>
<template>
<Page :auto-content-height="true">
<div class="flex h-full gap-2">
<div
ref="scrollContainer"
class="bg-background h-full w-[320px] overflow-y-auto rounded-lg py-3"
@scroll="handleScroll"
>
<div class="flex flex-col gap-2">
<ApprovalCard