feat: add utility to convert functional component to basic component vnode

This commit is contained in:
zernonia 2023-08-23 21:11:24 +08:00
parent afd3ad9102
commit 68fc41db1c

View File

@ -1,7 +1,8 @@
import type { ClassValue } from 'clsx'
import { clsx } from 'clsx'
import { twMerge } from 'tailwind-merge'
import { camelize, getCurrentInstance, toHandlerKey } from 'vue'
import type { FunctionalComponent } from 'vue'
import { camelize, defineComponent, getCurrentInstance, h, toHandlerKey } from 'vue'
export type ParseEmits<T extends Record<string, any>> = {
[K in keyof T]: (...args: T[K]) => void;
@ -31,3 +32,9 @@ export function useEmitAsProps<Name extends string>(
})
return result
}
export function convertToVNode(component: FunctionalComponent) {
return defineComponent({
setup() { return () => h(component) },
})
}