代码提交
This commit is contained in:
15
hooks/useScroll.js
Normal file
15
hooks/useScroll.js
Normal file
@ -0,0 +1,15 @@
|
||||
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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user