ktquez / vue-extend-layout

Default layout or create custom layouts for the pages of your Vue.js SPA (Multiple layouts)
https://vue-layouts2.surge.sh/
MIT License
131 stars 16 forks source link

How I can do router with child #10

Closed i-ked-ii closed 6 years ago

i-ked-ii commented 6 years ago

I have more link in website. I want to know, how to use vue-extend-layout with router child

ktquez commented 6 years ago

Added support for child routes. See example: https://github.com/ktquez/vue-extend-layout/blob/master/example/src/pages/About/index.vue https://github.com/ktquez/vue-extend-layout/blob/master/example/src/router.js

i-ked-ii commented 6 years ago

@ktquez Are your sure this code can use? I have problem.

[Vue warn]: Unknown custom element: <layout-default> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

My router

    {
        name: 'TournamentList',
        path: '/tournament',
        component: () => System.import('@/modules/tournament/views/List'),
        meta: {
            layout: 'layoutDefault'
        },
        children: [
            {
              name: 'List.Item',
              path: '/clash',
              component: () => System.import(/*  webpackChunkName: "User" */ '@/modules/tournament/views/Item')
            }
        ]
}
ktquez commented 6 years ago

src/layouts/default.vue

export default {
  name: 'default' // Instead of layoutDefault
}

your router

{
        name: 'TournamentList',
        path: '/tournament',
        component: () => System.import('@/modules/tournament/views/List'),
        meta: {
            layout: 'default' // optional, when it does not inform, the plugin takes the default layout
        },
        children: [
            {
              name: 'List.Item',
              path: '/clash',
              component: () => System.import(/*  webpackChunkName: "User" */ '@/modules/tournament/views/Item')
            }
        ]
}

E.g. https://github.com/ktquez/vue-extend-layout#create-and-using-layouts