Files
yshop-pro-uniapp/hooks/useScroll.js

16 lines
318 B
JavaScript
Raw Normal View History

2023-11-15 19:59:37 +08:00
import { onPageScroll } from "@dcloudio/uni-app";
import { onBeforeUnmount, ref } from "vue";
const scrollTop = ref(0)
export function useScroll(){
onPageScroll((e)=>{
scrollTop.value = e.scrollTop
})
onBeforeUnmount(()=>{
scrollTop.value = 0
})
return {
scrollTop
}
}