vue-router-layout Lightweight layout resolver for Vue Router.
Lightweight layout resolver for Vue Router.
You may want to use vue-cli-plugin-auto-routing which includes all useful features on routing.
$ npm install vue-router-layout
Create <RouterLayout>
component by passing a callback which resolves layout component to createRouterLayout
. The callback will receives a string of layout type and expect returning a promise resolves a layout component.
import { createRouterLayout } from 'vue-router-layout'
// Create <RouterLayout> component.
const RouterLayout = createRouterLayout(layout => {
// Resolves a layout component with layout type string.
return import('@/layouts/' + layout + '.vue')
})
Then, you pass <RouterLayout>
to Vue Router's routes
option with some children components.
import Vue from 'vue'
import Router from 'vue-router'
import { createRouterLayout } from 'vue-router-layout'
// Create <RouterLayout> component.
const RouterLayout = createRouterLayout(layout => {
// Resolves a layout component with layout type string.
return import('@/layouts/' + layout + '.vue')
})
Vue.use(Router)
export default new Router({
routes: [
{
path: '/',
// Pass <RouterLayout> as the route component
component: RouterLayout,
// All child components will be applied with corresponding layout component
children: [
{
path: '',
component: () => import('@/pages/index.vue')
}
]
}
]
})
With the above router, if you have layouts/foo.vue
and pages/index.vue
like the following:
<!-- layouts/foo.vue -->
<template>
<div>
<h1>Foo Layout</h1>
<router-view/>
</div>
</template>
<!-- pages/index.vue -->
<template>
<p>index.vue</p>
</template>
<script>
export default {
// You can specify layout component name here (default value is 'default')
layout: 'foo'
}
</script>
The following html will be rendered when you access /
route:
<div>
<h1>Foo Layout</h1>
<p>index.vue</p>
</div>
Author: ktsn
Source Code: https://github.com/ktsn/vue-router-layout
In this article, we are going to list out the most popular websites using Vue JS as their frontend framework. Vue JS is one of those elite progressive JavaScript frameworks that has huge demand in the web development industry. Many popular websites are developed using Vue in their frontend development because of its imperative features.
Vue Native is a framework to build cross platform native mobile apps using JavaScript. It is a wrapper around the APIs of React Native. So, with Vue Native, you can do everything that you can do with React Native. With Vue Native, you get
In this article, you’ll learn how to build a Vue custom select component that can be easily be styled using your own CSS. In fact, it’s the same component that we use in production on Qvault, and you can see it in action on the playground.
There are plenty of libraries out there that will have you up and running with a good tooltip solution in minutes. However, if you are like me, you are sick and tired of giant dependency trees that have the distinct possibility of breaking at any time.
Vue-ShortKey - The ultimate shortcut plugin to improve the UX .Vue-ShortKey - plugin for VueJS 2.x accepts shortcuts globaly and in a single listener.