refactor: fixed the problem that the scroll component could not remember the height
This commit is contained in:
parent
d2b532a760
commit
eff3277513
@ -1,13 +0,0 @@
|
|||||||
import { onActivated, onDeactivated } from 'vue'
|
|
||||||
|
|
||||||
export function useBase() {
|
|
||||||
const mainScroll = $ref()
|
|
||||||
const mainScrollTop = $ref(0)
|
|
||||||
onActivated(() => {
|
|
||||||
console.log('onActivated')
|
|
||||||
})
|
|
||||||
|
|
||||||
onDeactivated(() => {
|
|
||||||
console.log('onDeactivated')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
17
src/utils/hooks/useScroll.ts
Normal file
17
src/utils/hooks/useScroll.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { onActivated, onDeactivated, ref } from 'vue'
|
||||||
|
|
||||||
|
export function useScroll() {
|
||||||
|
const mainScroll = ref()
|
||||||
|
let mainScrollTop = $ref(0)
|
||||||
|
onActivated(() => {
|
||||||
|
if (mainScroll.value && mainScroll.value.wrapper) {
|
||||||
|
mainScroll.value.wrapper.scrollTop = mainScrollTop
|
||||||
|
}
|
||||||
|
})
|
||||||
|
onDeactivated(() => {
|
||||||
|
if (mainScroll.value && mainScroll.value.wrapper) {
|
||||||
|
mainScrollTop = mainScroll.value.wrapper.scrollTop
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return mainScroll
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user