在要记录滚动条位置的页面的路由,在mate里加上scrolltop:0 这个属性,然后在这个页面中,activeted中,去监听滚动条的方法,window.addeventlistener(“scroll”,this.scrollFn),去实时记录向上滚动的距离,在离开页面的方法中,deactiveted中销毁监听的方法,window.removeaddeventlistener(“scroll”,this.scrollFn)
下面是scrollFn方法
vue记录滚动条位置
于 2022-03-28 21:06:39 首次发布