2022-01-16 22:17:34 +08:00
|
|
|
import { defineAsyncComponent, AsyncComponentLoader } from 'vue'
|
2022-02-06 21:35:38 +08:00
|
|
|
import { AsyncLoading, AsyncSkeletonLoading } from '@/components/LoadingComponent'
|
2022-03-07 12:33:05 +08:00
|
|
|
|
2022-02-25 22:10:18 +08:00
|
|
|
/**
|
|
|
|
* * 动态注册组件
|
|
|
|
*/
|
|
|
|
export const componentInstall = <T> (key:string, node: T) => {
|
2022-03-06 21:26:31 +08:00
|
|
|
if(!window['$vue'].component(key) && node) {
|
2022-02-25 22:10:18 +08:00
|
|
|
window['$vue'].component(key, node)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-16 22:17:34 +08:00
|
|
|
/**
|
|
|
|
* * 异步加载组件
|
|
|
|
* @param loader
|
|
|
|
* @returns
|
|
|
|
*/
|
|
|
|
export const loadAsyncComponent = (loader: AsyncComponentLoader<any>) =>
|
|
|
|
defineAsyncComponent({
|
|
|
|
loader,
|
|
|
|
loadingComponent: AsyncLoading,
|
|
|
|
delay: 20,
|
|
|
|
})
|
2022-02-06 21:35:38 +08:00
|
|
|
|
|
|
|
export const loadSkeletonAsyncComponent = (loader: AsyncComponentLoader<any>) =>
|
|
|
|
defineAsyncComponent({
|
|
|
|
loader,
|
|
|
|
loadingComponent: AsyncSkeletonLoading,
|
|
|
|
delay: 20,
|
|
|
|
})
|