From 8edc71c92c9c291d76f7d1f3388c1f6b561883fb Mon Sep 17 00:00:00 2001 From: Sun <1652829889@qq.com> Date: Tue, 9 Jan 2024 18:10:04 +0800 Subject: [PATCH] fix(submit): duplicate triggering of the click event --- packages/components/src/submit/index.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/components/src/submit/index.tsx b/packages/components/src/submit/index.tsx index 782bcf2..d2e4559 100644 --- a/packages/components/src/submit/index.tsx +++ b/packages/components/src/submit/index.tsx @@ -2,12 +2,12 @@ import { observer } from '@formily/reactive-vue' import { useParentForm } from '@formily/vue' import type { ButtonProps } from 'ant-design-vue' import { Button } from 'ant-design-vue' -import { defineComponent } from 'vue' +import { defineComponent, type PropType } from 'vue' import type { IFormFeedback } from '@formily/core' export interface ISubmitProps extends ButtonProps { - onClick?: (e: MouseEvent) => any + onClick?: (event: MouseEvent) => void | boolean onSubmit?: (values: any) => any onSubmitSuccess?: (payload: any) => void onSubmitFailed?: (feedbacks: IFormFeedback[]) => void @@ -16,11 +16,14 @@ export interface ISubmitProps extends ButtonProps { export const Submit = observer( defineComponent({ name: 'FSubmit', + props: { + onClick: Function as PropType + }, setup(props, { attrs, slots }) { const formRef = useParentForm() return () => { - const { onClick, onSubmit, onSubmitSuccess, onSubmitFailed } = attrs + const { onSubmit, onSubmitSuccess, onSubmitFailed } = attrs const form = formRef?.value return (