diff --git a/packages/components/affix/src/affix.vue b/packages/components/affix/src/affix.vue index d7a9f8096a..e223eaeabf 100644 --- a/packages/components/affix/src/affix.vue +++ b/packages/components/affix/src/affix.vue @@ -12,6 +12,8 @@ import { computed, nextTick, + onActivated, + onDeactivated, onMounted, ref, shallowRef, @@ -158,6 +160,14 @@ onMounted(() => { updateRoot() }) +onActivated(() => { + nextTick(updateRootRect) +}) + +onDeactivated(() => { + fixed.value = false +}) + useEventListener(scrollContainer, 'scroll', handleScroll) watchEffect(update)