mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 17:43:59 +00:00
19 lines
396 B
TypeScript
19 lines
396 B
TypeScript
|
export default defineNuxtPlugin((_nuxtApp) => {
|
||
|
const router = useRouter()
|
||
|
|
||
|
router.beforeEach((to) => {
|
||
|
if (to.path !== '/add-route-test') { return }
|
||
|
if (router.getRoutes().some(route => route.path === to.path)) {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
router.addRoute({
|
||
|
path: to.path,
|
||
|
name: to.path,
|
||
|
component: () => import('~/pages/index.vue')
|
||
|
})
|
||
|
|
||
|
return to.path
|
||
|
})
|
||
|
})
|