diff --git a/packages/vant/src/composables/use-height.ts b/packages/vant/src/composables/use-height.ts index 083deccf2..68df222aa 100644 --- a/packages/vant/src/composables/use-height.ts +++ b/packages/vant/src/composables/use-height.ts @@ -1,5 +1,6 @@ import { useRect } from '@vant/use'; -import { Ref, ref, onMounted, nextTick } from 'vue'; +import { Ref, ref, onMounted, nextTick, watch } from 'vue'; +import { windowHeight, windowWidth } from '../utils'; import { onPopupReopen } from './on-popup-reopen'; export const useHeight = ( @@ -32,5 +33,9 @@ export const useHeight = ( // https://github.com/vant-ui/vant/issues/10628 onPopupReopen(() => nextTick(setHeight)); + // The height of the element may change when the window is resized + // https://github.com/youzan/vant/issues/11325 + watch([windowWidth, windowHeight], setHeight); + return height; };