优化滚动事件监听,启用 passive 选项以提升性能

beta
lyswhut 2025-05-09 09:04:43 +08:00
parent fe15e025aa
commit 2ccca633ed
2 changed files with 8 additions and 2 deletions

View File

@ -259,7 +259,10 @@ export default {
})
onMounted(() => {
dom_scrollContainer.value.addEventListener('scroll', onScroll, false)
dom_scrollContainer.value.addEventListener('scroll', onScroll, {
capture: false,
passive: true,
})
cachedList = Array(props.list.length)
startIndex = -1
endIndex = -1

View File

@ -282,7 +282,10 @@ export default {
})
onMounted(() => {
dom_scrollContainer.value.addEventListener('scroll', onScroll, false)
dom_scrollContainer.value.addEventListener('scroll', onScroll, {
capture: false,
passive: true,
})
cachedList = Array(props.list.length)
startIndex = -1
endIndex = -1