feat(core): support dynamic component via <component :is> (#320)
This commit is contained in:
@@ -1,13 +1,30 @@
|
||||
import { currentRenderingInstance } from '../componentRenderUtils'
|
||||
import { currentInstance, Component } from '../component'
|
||||
import { Directive } from '../directives'
|
||||
import { camelize, capitalize } from '@vue/shared'
|
||||
import {
|
||||
camelize,
|
||||
capitalize,
|
||||
isString,
|
||||
isObject,
|
||||
isFunction
|
||||
} from '@vue/shared'
|
||||
import { warn } from '../warning'
|
||||
|
||||
export function resolveComponent(name: string): Component | undefined {
|
||||
return resolveAsset('components', name)
|
||||
}
|
||||
|
||||
export function resolveDynamicComponent(
|
||||
component: unknown
|
||||
): Component | undefined {
|
||||
if (!component) return
|
||||
if (isString(component)) {
|
||||
return resolveAsset('components', component)
|
||||
} else if (isFunction(component) || isObject(component)) {
|
||||
return component
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveDirective(name: string): Directive | undefined {
|
||||
return resolveAsset('directives', name)
|
||||
}
|
||||
|
||||
@@ -39,7 +39,11 @@ export {
|
||||
// Internal, for compiler generated code
|
||||
// should sync with '@vue/compiler-core/src/runtimeConstants.ts'
|
||||
export { applyDirectives } from './directives'
|
||||
export { resolveComponent, resolveDirective } from './helpers/resolveAssets'
|
||||
export {
|
||||
resolveComponent,
|
||||
resolveDirective,
|
||||
resolveDynamicComponent
|
||||
} from './helpers/resolveAssets'
|
||||
export { renderList } from './helpers/renderList'
|
||||
export { toString } from './helpers/toString'
|
||||
export { toHandlers } from './helpers/toHandlers'
|
||||
|
||||
Reference in New Issue
Block a user