mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-17 03:14:46 +00:00
20 lines
653 B
TypeScript
20 lines
653 B
TypeScript
|
import { parseURL } from 'ufo'
|
||
|
import { defineComponent, h } from 'vue'
|
||
|
import { parseQuery } from 'vue-router'
|
||
|
|
||
|
export default (url:string) => defineComponent({
|
||
|
name: 'NuxtTestComponentWrapper',
|
||
|
|
||
|
async setup (props, { attrs }) {
|
||
|
const query = parseQuery(parseURL(url).search)
|
||
|
const urlProps = query.props ? JSON.parse(query.props as string) : {}
|
||
|
const comp = await import(/* @vite-ignore */ query.path as string).then(r => r.default)
|
||
|
return () => [
|
||
|
h('div', 'Component Test Wrapper for ' + query.path),
|
||
|
h('div', { id: 'nuxt-component-root' }, [
|
||
|
h(comp, { ...attrs, ...props, ...urlProps })
|
||
|
])
|
||
|
]
|
||
|
}
|
||
|
})
|