Skip to content

Commit 197d61a

Browse files
fix: 🐛 修复LockScroll后切换页面无法滚动 (#478)
Closes: #473
1 parent 84826f8 commit 197d61a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/uni_modules/wot-design-uni/components/composables/useLockScroll.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ref, watch } from 'vue'
1+
import { onBeforeUnmount, onDeactivated, ref, watch } from 'vue'
22

33
function useLockScroll(shouldLock: () => boolean) {
44
const scrollLockCount = ref(0)
@@ -19,10 +19,17 @@ function useLockScroll(shouldLock: () => boolean) {
1919
}
2020
}
2121

22+
const destroy = () => {
23+
shouldLock() && unlock()
24+
}
25+
2226
watch(shouldLock, (value) => {
2327
value ? lock() : unlock()
2428
})
2529

30+
onDeactivated(destroy)
31+
onBeforeUnmount(destroy)
32+
2633
return {
2734
lock,
2835
unlock

0 commit comments

Comments
 (0)