perf: 为createAsyncComponent函数增加类型推导
parent
c4425a8286
commit
f1bc5e738a
|
@ -1,3 +1,8 @@
|
||||||
|
import type {
|
||||||
|
AsyncComponentLoader,
|
||||||
|
Component,
|
||||||
|
ComponentPublicInstance,
|
||||||
|
} from 'vue'
|
||||||
import {
|
import {
|
||||||
defineAsyncComponent,
|
defineAsyncComponent,
|
||||||
// FunctionalComponent, CSSProperties
|
// FunctionalComponent, CSSProperties
|
||||||
|
@ -27,7 +32,11 @@ interface Options {
|
||||||
retry?: boolean
|
retry?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createAsyncComponent(loader: Fn, options: Options = {}) {
|
export function createAsyncComponent<
|
||||||
|
T extends Component = {
|
||||||
|
new (): ComponentPublicInstance
|
||||||
|
},
|
||||||
|
>(loader: AsyncComponentLoader<T>, options: Options = {}) {
|
||||||
const { size = 'small', delay = 100, timeout = 30000, loading = false, retry = true } = options
|
const { size = 'small', delay = 100, timeout = 30000, loading = false, retry = true } = options
|
||||||
return defineAsyncComponent({
|
return defineAsyncComponent({
|
||||||
loader,
|
loader,
|
||||||
|
|
Loading…
Reference in New Issue