From 68fc41db1cc573386671647f8554cbf95f905fe7 Mon Sep 17 00:00:00 2001 From: zernonia Date: Wed, 23 Aug 2023 21:11:24 +0800 Subject: [PATCH] feat: add utility to convert functional component to basic component vnode --- apps/www/src/lib/utils.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/www/src/lib/utils.ts b/apps/www/src/lib/utils.ts index e1d860eb..834ed631 100644 --- a/apps/www/src/lib/utils.ts +++ b/apps/www/src/lib/utils.ts @@ -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> = { [K in keyof T]: (...args: T[K]) => void; @@ -31,3 +32,9 @@ export function useEmitAsProps( }) return result } + +export function convertToVNode(component: FunctionalComponent) { + return defineComponent({ + setup() { return () => h(component) }, + }) +}