Commit 6d5f9aa699c5da8af6bf5841baddc4a8bd603917

Authored by 无木
1 parent 21f7a854

feat(modal): add closeModal for useModal

src/components/Modal/src/hooks/useModal.ts
... ... @@ -90,6 +90,10 @@ export function useModal(): UseModalReturnType {
90 90 dataTransferRef[unref(uidRef)] = toRaw(data);
91 91 }
92 92 },
  93 +
  94 + closeModal: () => {
  95 + getInstance()?.setModalProps({ visible: false });
  96 + },
93 97 };
94 98 return [register, methods];
95 99 }
... ...
src/components/Modal/src/types.ts
... ... @@ -13,6 +13,7 @@ export type RegisterFn = (modalMethods: ModalMethods, uuid?: string) => void;
13 13  
14 14 export interface ReturnMethods extends ModalMethods {
15 15 openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void;
  16 + closeModal: () => void;
16 17 getVisible?: ComputedRef<boolean>;
17 18 }
18 19  
... ...