上锁
This commit is contained in:
parent
3dc759235a
commit
57a6e31b44
@ -97,28 +97,24 @@ const 屏幕宽高重置 = () => {
|
||||
WIDTH.value = 列宽
|
||||
};
|
||||
|
||||
const disabled = ref(false); // 上锁
|
||||
const inadvance = ref(400); // 距离
|
||||
const page = ref(3) // 页码
|
||||
const disabled = ref(false) // 上锁
|
||||
const inadvance = ref(400) // 距离
|
||||
|
||||
const page = ref(3); // 页码
|
||||
const nextPage = () => {
|
||||
fetch(`/api/gallery?page=${page.value}`).then((res) => {
|
||||
page.value = page.value + 1;
|
||||
disabled.value = false;
|
||||
if (res.status === 200) {
|
||||
res.json().then((rest) => {
|
||||
data.value = data.value.concat(rest)
|
||||
});
|
||||
fetch(`/api/gallery?page=${page.value}`).then(res => res.json()).then(data => {
|
||||
page.value = page.value + 1
|
||||
disabled.value = !!data.length
|
||||
data.value = data.value.concat(data)
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleScroll = () => {
|
||||
if (disabled.value) return;
|
||||
const { scrollHeight, scrollTop, clientHeight } = document.documentElement;
|
||||
if (scrollHeight - scrollTop - clientHeight <= inadvance.value) {
|
||||
disabled.value = true // 加载期间上锁
|
||||
console.log("scroll to bottom");
|
||||
disabled.value = true; // 加载期间上锁
|
||||
inadvance.value = 1280; // 加高判定值使卡顿感减弱
|
||||
nextPage();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user