Vue-router: [2.0] Waring about named route with default child route not showing in non-minified build

Created on 14 Oct 2016  ·  5Comments  ·  Source: vuejs/vue-router

When i use <router-link :to="{ name: 'home' }">/home</router-link>, i can't get the correct results. See.

But <router-link to="/home">/home</router-link> is right. See

When use router.push, the result is same as the first case.

Please help me, thanks.

2.x improvement

Most helpful comment

You _should_ be seeing a warning about this, but appearntly there's a problem with that. I will check that out.

The warning _does_ appear when you use e.g. the vue-cli webpack template and have run npm run dev

The warning would read:

Named Route 'home' has a default child route.
When navigating to this named route (:to="{name: 'home'"), the default child route will not be rendered.
Remove the name from this route and use the name of the default child route for named links instead.`

Which esseantially means your route config should look like this:

const router = new VueRouter({
  routes: [
    { path: '/home', component: resolve => resolve(Home),
      children: [
        { path: '', name: 'home', component: resolve => resolve(Welcome) },
        { path: 'welcome', name: 'welcome', component: resolve => resolve(Welcome) },
      ]
    }
  ]
})

Sorry for the inconvenience, will see how to fix that the non-minified release does show the warning in the future, but it apüpears that warnings in this build are not shown generally.

All 5 comments

You _should_ be seeing a warning about this, but appearntly there's a problem with that. I will check that out.

The warning _does_ appear when you use e.g. the vue-cli webpack template and have run npm run dev

The warning would read:

Named Route 'home' has a default child route.
When navigating to this named route (:to="{name: 'home'"), the default child route will not be rendered.
Remove the name from this route and use the name of the default child route for named links instead.`

Which esseantially means your route config should look like this:

const router = new VueRouter({
  routes: [
    { path: '/home', component: resolve => resolve(Home),
      children: [
        { path: '', name: 'home', component: resolve => resolve(Welcome) },
        { path: 'welcome', name: 'welcome', component: resolve => resolve(Welcome) },
      ]
    }
  ]
})

Sorry for the inconvenience, will see how to fix that the non-minified release does show the warning in the future, but it apüpears that warnings in this build are not shown generally.

Ok, i get it, thanks.

Am getting this error appeared on my app. Am using vue-router 2.6.0, is this fixed?

The error is telling you what to do, just follow the instructions.

Was this page helpful?
0 / 5 - 0 ratings