Coder Social home page Coder Social logo

layout-simple's Introduction

layout-simple

A simple Webpack + Extend layout

Using vue-extend-layout package, inspired in layouts of the Nuxt.js

This template is Vue 2.0 compatible

Documentation where this template was based

Usage

This is a project template for vue-cli.

$ npm install -g vue-cli
$ vue init ktquez/layout-simple my-project
$ cd my-project
$ npm install
$ npm run dev

Using layouts

By default, there are 2 layout components in the directory layouts/:

  • layouts/default.vue => Is the default application extend layout
  • layouts/error.vue => This is the layout for error page

Both are already configured in the route file For example:

...
export default new Router({
  mode: 'history',
  base: '/',
  routes: [
    {
      path: '/',
      name: 'Hello',
      component: () => import('@/pages/Hello'),
      // Setting layout when default, is optional, no need to set.
    },
    {
      path: '*',
      name: 'Error',
      meta: {
        layout: 'error' // error layout for route mismatch
      }
    }
  ]
})

Custom extend layout

To create a layout you just need to create a component within the layouts directory and name that component.

For example: layouts/myCustomLayoutLogin.vue

<template>
  <div>
    <router-view />
  </div>
</template>

<script>
  export default {
    name: 'myCustomLayoutLogin' // id of the layout
  }
</script>

<style>
/* your style */
</style>

And to extend this layout in any the desired route, simply include the property layout: myCustomLayoutLogin in meta object of the route.

{
  path: '/login',
  name: 'Login',
  component: () => import('@/pages/Login'),
  meta: {
    layout: 'myCustomLayoutLogin' // name of the layout
  }
}

Attention: The value of the layout property must be the same as the name of the myCustomLayoutLogin component.

Articles and Screencast

  • In development

Contributing

  • Check the open issues or open a new issue to start a discussion around your feature idea or the bug you found.
  • Fork repository, make changes, add your name and link in the contributors session readme.md
  • Send a pull request

If you want a faster communication, check out my blog ktquez.com or find me on Twitter @ktquez

Thank you for using!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.