From: Eduardo San Martin Morote Date: Sat, 29 May 2021 13:26:25 +0000 (+0200) Subject: chore: plaground transparent wrapper X-Git-Tag: v4.0.9~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7331ef7d40f5013cb9ed013fa5d7a8a151fb95d;p=thirdparty%2Fvuejs%2Frouter.git chore: plaground transparent wrapper --- diff --git a/playground/main.ts b/playground/main.ts index defbc8f7..0fca869c 100644 --- a/playground/main.ts +++ b/playground/main.ts @@ -1,6 +1,6 @@ // necessary for webpack /// -import { createApp, App as Application } from 'vue' +import { createApp, ComponentPublicInstance } from 'vue' import { router, routerHistory } from './router' import { globalState } from './store' import App from './App.vue' @@ -10,7 +10,8 @@ declare global { // h: HTML5History h: typeof routerHistory r: typeof router - vm: ReturnType + // @ts-expect-error + vm: ComponentPublicInstance } } @@ -19,6 +20,12 @@ window.h = routerHistory window.r = router const app = createApp(App) +app.mixin({ + beforeRouteEnter() { + console.log('mixin enter') + }, +}) + app.provide('state', globalState) app.use(router) diff --git a/playground/router.ts b/playground/router.ts index a98dddce..cab05b8e 100644 --- a/playground/router.ts +++ b/playground/router.ts @@ -1,4 +1,4 @@ -import { createRouter, createWebHistory } from '../src' +import { createRouter, createWebHistory, RouterView } from '../src' import Home from './views/Home.vue' import Nested from './views/Nested.vue' import NestedWithId from './views/NestedWithId.vue' @@ -15,8 +15,12 @@ import ComponentWithData from './views/ComponentWithData.vue' import { globalState } from './store' import { scrollWaiter } from './scrollWaiter' import RepeatedParams from './views/RepeatedParams.vue' +import { FunctionalComponent, h } from 'vue' let removeRoute: (() => void) | undefined +const TransparentWrapper: FunctionalComponent = () => h(RouterView) +TransparentWrapper.displayName = 'NestedView' + export const routerHistory = createWebHistory() export const router = createRouter({ history: routerHistory, @@ -147,6 +151,16 @@ export const router = createRouter({ } else next() }, }, + + { + path: '/admin', + component: TransparentWrapper, + children: [ + { path: '', component }, + { path: 'dashboard', component }, + { path: 'settings', component }, + ], + }, ], async scrollBehavior(to, from, savedPosition) { await scrollWaiter.wait() diff --git a/playground/views/Generic.vue b/playground/views/Generic.vue index 8079c805..4dd18afb 100644 --- a/playground/views/Generic.vue +++ b/playground/views/Generic.vue @@ -1,5 +1,8 @@