拆分路由

This commit is contained in:
iizmg
2020-05-27 14:55:56 +08:00
parent 2b74cd88bb
commit 5008e877bd
3 changed files with 37 additions and 19 deletions
+12
View File
@@ -0,0 +1,12 @@
export default [
{
path: '/article',
name: '/article',
component: () => import('../components/artice/main'),
},
{
path: '/article/add',
name: '/article/add',
component: () => import('../components/artice/add'),
}
];
+7
View File
@@ -0,0 +1,7 @@
export default [
{
path: '/',
name: 'home',
component: () => import('../components/home'),
},
];
+18 -19
View File
@@ -1,21 +1,20 @@
export default new VueRouter({
// mode: 'history',
base: `${process.env.VUE_APP_ADMIN_BASE_URL}`,
routes: [
{
path: '/',
name: 'home',
component: () => import('../components/home'),
},
{
path: '/article',
name: '/article',
component: () => import('../components/artice/main'),
},
{
path: '/article/add',
name: '/article/add',
component: () => import('../components/artice/add'),
import article from "./article";
import home from "./home";
const routes = (() => {
let routes = [];
[
home,
article
].forEach(item => {
if (Array.isArray(item)) {
routes = routes.concat(item);
}
]
});
return routes;
})();
export default new VueRouter({
base: `${process.env.VUE_APP_ADMIN_BASE_URL}`,
routes: routes
});