fix(Modal): repair cancel event missing (#1545)

This commit is contained in:
bingzhe 2021-12-28 18:42:03 +08:00 committed by GitHub
parent f015a874e2
commit b84cc5eb06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,7 +10,7 @@ export default defineComponent({
inheritAttrs: false,
props: basicProps,
emits: ['cancel'],
setup(props, { slots }) {
setup(props, { slots, emit }) {
const { visible, draggable, destroyOnClose } = toRefs(props);
const attrs = useAttrs();
useModalDragMove({
@ -19,8 +19,12 @@ export default defineComponent({
draggable,
});
const onCancel = (e: Event) => {
emit('cancel', e);
};
return () => {
const propsData = { ...unref(attrs), ...props } as Recordable;
const propsData = { ...unref(attrs), ...props, onCancel } as Recordable;
return <Modal {...propsData}>{extendSlots(slots)}</Modal>;
};
},