tao-vue-auto-router

1.0.0 • Public • Published

info

how to use

import Vue from "vue";
import VueRouter from "vue-router";
import routerHandler from "vue-auto-router";
Vue.use(VueRouter);

const views = require.context("./../views/", true, /\.vue$/);

const routes = new routerHandler({ views }).load();

const router = new VueRouter({
	mode: "hash",
	base: process.env.BASE_URL,
	routes,
});

export default router;

rule

if your views like:

views/
--| one.vue
--| two.vue
--| music/
-----| index.vue
-----| one.vue
-----| two.vue

this router like:

[
    {
        name:'one',
        path:'/one',
        component: () => import('@/views/one.vue')
    },
    {
        name:'two',
        path:'/two',
        component: () => import('@/views/two.vue')
    },
    {
        name:'music',
        path:'/music',
        component: () => import('@/views/music/index.vue')
        children:[
            {
                name:'one',
                path:'one',
                component: () => import('@/views/music/one.vue')
            },
            {
                name:'two',
                path:'two',
                component: () => import('@/views/music/two.vue')
            }
        ]
    }
]

Readme

Keywords

none

Package Sidebar

Install

npm i tao-vue-auto-router

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

7.12 kB

Total Files

3

Last publish

Collaborators

  • laxnpm