vuejs / router

🚦 The official router for Vue.js

Home Page:https://router.vuejs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Named components but not default component in a route with redirect to a child

euberdeveloper opened this issue · comments

Reproduction

https://codesandbox.io/p/sandbox/reverent-heisenberg-sw2s4d

Steps to reproduce the bug

I have a code like this:

{
          path: 'auth',
          name: 'auth',
          redirect: { name: 'login' },
          component: {
            default: AuthProxyView,
            bar: MainBar,
            menu: MainMenu
          },
          children: [
            {
              path: 'login',
              name: 'login',
              component: LoginView,
              meta: {
                title: 'login'
              }
            }
         ]
}

And I want to remove AuthProxyView, because it actually is not needed, it's just another component.

If I remove it, "AnonymousComponent" is used as default and nothing is shown instead.

Expected behavior

A stub " " component should be used by default for the default component in the route

Actual behavior

No component is passed and the main view is blank

Additional information

In the CodeSandbox, the reproduction is similar.

To make it work, uncomment // default: Stub,

This is working as intended: In order to use nested routes, you will need that <RouterView />. If it's always done, you will need to add an empty component to display nothing which would be counter intuitive.

When there are not named views, this is not the current behaviour.

https://github.com/vuejs/router/releases/tag/v4.1.0
"Omitting the component/components option in routes"