Skip to content

Instantly share code, notes, and snippets.

@darkylmnx
Last active July 30, 2018 22:11
Show Gist options
  • Select an option

  • Save darkylmnx/6754e54db6eb43bf4acccf116745735e to your computer and use it in GitHub Desktop.

Select an option

Save darkylmnx/6754e54db6eb43bf4acccf116745735e to your computer and use it in GitHub Desktop.

Revisions

  1. darkylmnx revised this gist Jul 30, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion LayoutC.vue
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    <template>
    <div>
    <the-header />
    <h1> i'm layout A1 </h1>
    <h1> i'm layout C </h1>

    <!-- let's use the sub layout -->
    <a-sub-layout>
  2. darkylmnx revised this gist Jul 30, 2018. 2 changed files with 1 addition and 1 deletion.
    File renamed without changes.
    2 changes: 1 addition & 1 deletion router.js
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ new VueRouter({
    {
    name: 'some-random-page',
    path: '/bla1',
    meta: {layout: 'LayoutA1' },
    meta: {layout: 'LayoutC' },
    component: () => import('@/pages/Random1.vue')
    },
    {
  3. darkylmnx revised this gist Jul 30, 2018. 4 changed files with 30 additions and 4 deletions.
    File renamed without changes.
    4 changes: 2 additions & 2 deletions LayoutA.vue
    Original file line number Diff line number Diff line change
    @@ -4,10 +4,10 @@
    <h1> i'm layout A </h1>

    <!-- let's use the sub layout -->
    <sub-layout-a>
    <a-sub-layout>
    <slot />
    <!-- here we are doing slot transfer, the main component will appear within the sub layout -->
    </sub-layout-a>
    </a-sub-layout>

    <!-- here we have a footer -->
    <the-footer />
    4 changes: 2 additions & 2 deletions LayoutA1.vue
    Original file line number Diff line number Diff line change
    @@ -4,10 +4,10 @@
    <h1> i'm layout A1 </h1>

    <!-- let's use the sub layout -->
    <sub-layout-a>
    <a-sub-layout>
    <slot />
    <!-- here we are doing slot transfer, the main component will appear within the sub layout -->
    </sub-layout-a>
    </a-sub-layout>

    <!-- no footer here -->
    </div>
    26 changes: 26 additions & 0 deletions router.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    // as you will notice
    // we never use a sub layout directly
    // sub layouts are only used to contain common markup for main layouts

    new VueRouter({
    routes: [
    {
    name: 'home',
    path: '/',
    meta: {layout: 'LayoutA' },
    component: require('@/pages/Home.vue').default // load sync mode
    },
    {
    name: 'some-random-page',
    path: '/bla1',
    meta: {layout: 'LayoutA1' },
    component: () => import('@/pages/Random1.vue')
    },
    {
    name: 'some-random-page-2',
    path: '/bla2',
    meta: {layout: 'LayoutB' },
    component: () => import('@/pages/Random2.vue')
    }
    ]
    })
  4. darkylmnx created this gist Jul 30, 2018.
    15 changes: 15 additions & 0 deletions LayoutA.vue
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    <template>
    <div>
    <the-header />
    <h1> i'm layout A </h1>

    <!-- let's use the sub layout -->
    <sub-layout-a>
    <slot />
    <!-- here we are doing slot transfer, the main component will appear within the sub layout -->
    </sub-layout-a>

    <!-- here we have a footer -->
    <the-footer />
    </div>
    <template>
    14 changes: 14 additions & 0 deletions LayoutA1.vue
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    <template>
    <div>
    <the-header />
    <h1> i'm layout A1 </h1>

    <!-- let's use the sub layout -->
    <sub-layout-a>
    <slot />
    <!-- here we are doing slot transfer, the main component will appear within the sub layout -->
    </sub-layout-a>

    <!-- no footer here -->
    </div>
    <template>
    14 changes: 14 additions & 0 deletions LayoutB.vue
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    <template>
    <div>
    <the-header />
    <h1> i'm layout B</h1>

    <aside> i'm a side bar</aside>

    <slot />
    <!-- no sub layout -->
    <!-- the main compoent will apppear hear as a slot -->

    </the-footer />
    </div>
    </template>
    7 changes: 7 additions & 0 deletions SubLayoutA.vue
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    <template>
    <!-- this layout will not have any header or general things to all layouts -->
    <div>
    <h2> i'm a sub layout </h2>
    <slot />
    </div>
    </template>
    3 changes: 3 additions & 0 deletions TheFooter.vue
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    <template>
    <footer> hey i'm the footer </footer>
    </template>
    3 changes: 3 additions & 0 deletions TheHeader.vue
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    <template>
    <header> hey i'm the header </header>
    </template>