Nuxt/packages/nuxt3/src/pages/runtime/utils.ts

16 lines
506 B
TypeScript
Raw Normal View History

import { Component, KeepAlive, h } from 'vue'
const Fragment = {
setup (_props, { slots }) {
return () => slots.default()
}
}
export const wrapIf = (component: Component, props: any, slots: any) => {
return { default: () => props ? h(component, props === true ? {} : props, slots) : h(Fragment, {}, slots) }
}
export const wrapInKeepAlive = (props: any, children: any) => {
return { default: () => process.client && props ? h(KeepAlive, props === true ? {} : props, children) : children }
}