feat(use-loading): add setTip method

为useLoading添加setTip方法
This commit is contained in:
无木 2021-07-30 16:59:52 +08:00
parent ddd1893b11
commit 26d9476caf
2 changed files with 11 additions and 4 deletions

View File

@ -2,6 +2,7 @@
- **Preview** 添加新的属性及事件
- **Dark Theme** 新增对 tailwindcss 夜间模式的支持
- **其它** 为 useLoading 添加 setTip 方法
### 🐛 Bug Fixes

View File

@ -12,10 +12,12 @@ interface Fn {
(): void;
}
export function useLoading(props: Partial<LoadingProps>): [Fn, Fn];
export function useLoading(opt: Partial<UseLoadingOptions>): [Fn, Fn];
export function useLoading(props: Partial<LoadingProps>): [Fn, Fn, (string) => void];
export function useLoading(opt: Partial<UseLoadingOptions>): [Fn, Fn, (string) => void];
export function useLoading(opt: Partial<LoadingProps> | Partial<UseLoadingOptions>): [Fn, Fn] {
export function useLoading(
opt: Partial<LoadingProps> | Partial<UseLoadingOptions>
): [Fn, Fn, (string) => void] {
let props: Partial<LoadingProps>;
let target: HTMLElement | Ref<ElRef> = document.body;
@ -39,5 +41,9 @@ export function useLoading(opt: Partial<LoadingProps> | Partial<UseLoadingOption
instance.close();
};
return [open, close];
const setTip = (tip: string) => {
instance.setTip(tip);
};
return [open, close, setTip];
}