vue-router-def
v0.0.3
Published
vue-router component require part simple definition
Downloads
6
Maintainers
Readme
#说明
在使用 vue-router 时, 我们需要这样定义:
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router);
export default new Router({
mode: 'hash',
routes: [
{
path: '/',
redirect: '/show'
},
{
path: '/show',
component: resolve => require(['../components/home/HomePage.vue'], resolve)
},
{
path: '/basicinfo',
component: resolve => require(['../components/info/Info.vue'], resolve),
children: [
{
path: '',
component: resolve => require(['../components/info/BasicInfo.vue'], resolve),
},
{
path: '/receiveaddress',
component: resolve => require(['../components/info/ReceiveAddress.vue'], resolve)
}
]
},
。。。(更多定义)
}
}
这样在查看路由表时,比较乱。 vue_router_def 可以使用如下方式进行定义。
import Vue from 'vue'
import Router from 'vue-router'
import router_def from 'vue-router-def'
Vue.use(Router);
var map = {};
map["/show"] = "../components/home/HomePage.vue";
map["/basicinfo"] = "../components/info/BasicInfo.vue";
map["/basicinfo#"] = "../components/info/Info.vue";
map["/basicinfo/receiveaddress"] = "../components/info/ReceiveAddress.vue";
var routes = [{path: '/',redirect: '/show'}];
routes.push.apply(routes, window.vue_router_def(map));
export default new Router({
mode: 'hash',
routes: routes
}