Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
821 views
in Technique[技术] by (71.8m points)

routes - Vue-router 4 - parent redirect : Maximum call stack exceeded

I've done this multiple times, but with the new vue-router(v4.0.3) i get an Maximum call stack exceeded. I've got an layout component with a router-view. I redirect the parent route to the child route, so i can use the active classes on the <router-link/>.

Is there something wrong with my code?

Layout template

<template>
    <div class="layout">
        <transition name="animation-fade">
            <router-view />
        </transition>
    </div>
</template>

Router config courses.ts

export default [{
    path: '/courses',
    name: 'courses',
    redirect: '/courses/all',
    template: '<router-view/>',
    children: [
        {
            path: 'all',
            name: 'coursesAll',
            component: Courses,
        },
        {
            path: ':id',
            name: 'courseSingle',
            component: CourseSingle,
        }
    ]
}]

Router

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes (includes course routes)
})

router.beforeEach((to, from, next) => {
    next()
})

export default router;

question from:https://stackoverflow.com/questions/65829030/vue-router-4-parent-redirect-maximum-call-stack-exceeded

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...