Skip to content

Commit

Permalink
fix: 解决组件使用keep-alive缓存后resize还一直在计算的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
vaemusic committed May 22, 2024
1 parent 0bd776a commit 5b7f8d4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/datav-vue3/utils/autoResize.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { Ref } from 'vue'
import { useDebounceFn, useEventListener } from '@vueuse/core'
import { nextTick, onMounted, onUnmounted, ref } from 'vue'
import { nextTick, onActivated, onDeactivated, onMounted, onUnmounted, ref } from 'vue'
import { observerDomResize } from './index'
const autoResize = (dom: Ref<HTMLElement | null>, onResize?: () => void, afterAutoResizeMixinInit?: () => void) => {

function autoResize(dom: Ref<HTMLElement | null>, onResize?: () => void, afterAutoResizeMixinInit?: () => void) {
const width = ref(0)
const height = ref(0)

Expand Down Expand Up @@ -65,6 +66,10 @@ const autoResize = (dom: Ref<HTMLElement | null>, onResize?: () => void, afterAu
unbindDomResizeCallback()
})

onActivated(autoResizeMixinInit)

onDeactivated(unbindDomResizeCallback)

return {
width,
height,
Expand Down

0 comments on commit 5b7f8d4

Please sign in to comment.