From 233886aa905760e601243025b60c65dfa5094244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E8=83=BD=E6=9D=83?= <674370@ky-tech.com.cn> Date: Fri, 16 Jan 2026 15:57:29 +0800 Subject: [PATCH] fix(Popup): add PopupEmitsProps to Popup --- packages/vant/src/action-sheet/ActionSheet.tsx | 16 ++++++++-------- packages/vant/src/dialog/Dialog.tsx | 4 ++-- packages/vant/src/popup/index.ts | 6 ++++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/vant/src/action-sheet/ActionSheet.tsx b/packages/vant/src/action-sheet/ActionSheet.tsx index 08e73a56ea0..628b7d1b987 100644 --- a/packages/vant/src/action-sheet/ActionSheet.tsx +++ b/packages/vant/src/action-sheet/ActionSheet.tsx @@ -1,21 +1,21 @@ -import { nextTick, defineComponent, type ExtractPropTypes } from 'vue'; +import { defineComponent, nextTick, type ExtractPropTypes } from 'vue'; // Utils import { - pick, + createNamespace, extend, - truthProp, + HAPTICS_FEEDBACK, makeArrayProp, makeStringProp, - createNamespace, - HAPTICS_FEEDBACK, + pick, + truthProp, } from '../utils'; // Components import { Icon } from '../icon'; -import { Popup } from '../popup'; import { Loading } from '../loading'; -import { popupSharedProps, popupSharedPropKeys } from '../popup/shared'; +import { Popup, PopupEmitsProps } from '../popup'; +import { popupSharedPropKeys, popupSharedProps } from '../popup/shared'; const [name, bem] = createNamespace('action-sheet'); @@ -59,7 +59,7 @@ export default defineComponent({ emits: ['select', 'cancel', 'update:show'], - setup(props, { slots, emit }) { + setup(props: ActionSheetProps & PopupEmitsProps, { emit, slots }) { const updateShow = (show: boolean) => emit('update:show', show); const onCancel = () => { diff --git a/packages/vant/src/dialog/Dialog.tsx b/packages/vant/src/dialog/Dialog.tsx index e94c475a00a..146622ae5ac 100644 --- a/packages/vant/src/dialog/Dialog.tsx +++ b/packages/vant/src/dialog/Dialog.tsx @@ -27,7 +27,7 @@ import { import { popupSharedProps, popupSharedPropKeys } from '../popup/shared'; // Components -import { Popup } from '../popup'; +import { Popup, PopupEmitsProps } from '../popup'; import { Button } from '../button'; import { ActionBar } from '../action-bar'; import { ActionBarButton } from '../action-bar-button'; @@ -82,7 +82,7 @@ export default defineComponent({ emits: ['confirm', 'cancel', 'keydown', 'update:show'], - setup(props, { emit, slots }) { + setup(props: DialogProps & PopupEmitsProps, { emit, slots }) { const root = ref(); const loading = reactive({ confirm: false, diff --git a/packages/vant/src/popup/index.ts b/packages/vant/src/popup/index.ts index 52a2ad6c482..6135e1e03ab 100644 --- a/packages/vant/src/popup/index.ts +++ b/packages/vant/src/popup/index.ts @@ -1,3 +1,4 @@ +import { EmitsToProps } from 'vue'; import { withInstall } from '../utils'; import _Popup from './Popup'; @@ -5,6 +6,11 @@ export const Popup = withInstall(_Popup); export default Popup; export { popupProps } from './Popup'; export type { PopupProps } from './Popup'; + +export type PopupEmitsProps = EmitsToProps< + NonNullable<(typeof Popup)['emits']> +>; + export type { PopupPosition, PopupInstance,