wupengfei
10 天以前 a0c1d9021b1a65cc397a2c7a8a9d226c2d9f7539
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { ElLoading } from 'element-plus';
 
export function useLoading(config?: { text: string; background?: string }) {
  return new Promise<() => void>((resolve, _reject) => {
    const loading = ElLoading.service({
      lock: true,
      text: config?.text ?? '加载中',
      background: config?.background ?? 'rgba(0, 0, 0, 0)',
    });
 
    resolve(() => {
      loading.close();
    });
  });
}