UNPKG

@esmx/router-vue

Version:

Vue integration for @esmx/router - A universal router that works seamlessly with both Vue 2.7+ and Vue 3

16 lines (15 loc) 518 B
import { defineComponent, h } from "vue"; import { _useRouterViewDepth, useRoute } from "./use.mjs"; import { resolveComponent } from "./util.mjs"; export const RouterView = defineComponent({ name: "RouterView", setup() { const route = useRoute(); const depth = _useRouterViewDepth(true); return () => { const matchedRoute = route.matched[depth]; const component = matchedRoute ? resolveComponent(matchedRoute.component) : null; return component ? h(component) : null; }; } });