feat(modal): add closeModal for useModal

This commit is contained in:
无木 2021-06-08 10:55:33 +08:00
parent 21f7a854fe
commit 6d5f9aa699
2 changed files with 5 additions and 0 deletions

View File

@ -90,6 +90,10 @@ export function useModal(): UseModalReturnType {
dataTransferRef[unref(uidRef)] = toRaw(data); dataTransferRef[unref(uidRef)] = toRaw(data);
} }
}, },
closeModal: () => {
getInstance()?.setModalProps({ visible: false });
},
}; };
return [register, methods]; return [register, methods];
} }

View File

@ -13,6 +13,7 @@ export type RegisterFn = (modalMethods: ModalMethods, uuid?: string) => void;
export interface ReturnMethods extends ModalMethods { export interface ReturnMethods extends ModalMethods {
openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void; openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void;
closeModal: () => void;
getVisible?: ComputedRef<boolean>; getVisible?: ComputedRef<boolean>;
} }