Vue 頁面滾動事件捕捉不到,觸底更新

2022-05-28 21:15:30 字數 760 閱讀 8201

使用這種辦法始終是沒有觸發

window.addeventlistener('scroll',()=>)

然後找一下觸發到了誰在滾動

performance ->點選錄製 然後滾動你的頁面 ,然後點選stop 停止錄製⏺,就會生成錄製的資料

在event_log 的搜尋項中 搜關鍵字 scroll 如果沒有 重新錄製一遍,選擇紫色的 然後右邊就找到了滾動的節點

找到這個節點 然後加上滾動事件

就可以抓到滾動事件了, ye

然後觸底更新 就需要針對這個元素來進行判斷了(我是抓 m-main 這個class 的)

//獲取windows的高度

getwindowheight() ,

//獲取已經滾動的高度

getscrollheight() ,

//獲取滾動dom的總高度

getdocumenttop() ,

//windows高度+已經滾動的高度》 滾動dom總高度

letisbottom

= (this.getscrollheight() +

this.getwindowheight()) >=

this.getdocumenttop()

if (isbottom)

雨雀位址

js 捕捉滾動條事件

這裡是1 a br a href p2 這裡是2 a br a href p3 這裡是3 a br a href p4 這裡是4 a br a href p5 這裡是5 a br a href p6 這裡是6 a br a href p7 這裡是7 a br a href p8 這裡是8 a br ...

頁面滾動事件scroll

在mounted鉤子函式裡面註冊scroll事件 mounted window.addeventlistener scroll this.about methods 判斷元素到達當前視窗的什麼位置 簡介 let isup true let titlediv document.getelementsb...

vue監聽滾動事件

vue中監聽滾動事件,然後對其進行事件處理,一般有 1.滾動到頂部吸附 2.根據滾動的位置啟用對應的tab鍵 錨鏈結tab鍵 這兩種方式的處理都是可通過監聽scroll來實現 mounted 處理方法 1.滾動到頂部吸附 html元素 這個是要滾動到頂部吸附的元素 methods方法 handles...