mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-10 19:36:46 +08:00
style:增加左侧导航及头部导航栏
This commit is contained in:
16
src/router/config.js
Normal file
16
src/router/config.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const routes = [];
|
||||
const context = require.context('@/views', true, /\.vue$/, 'lazy');
|
||||
context.keys().forEach(path => {
|
||||
// console.log('path', path)
|
||||
const componentName = path.replace(/.*\/([^\\.\\/]*)\.vue$/, '$1');
|
||||
routes.push({
|
||||
path: `/${componentName.toLowerCase()}`,
|
||||
name: componentName,
|
||||
component: () => context(path),
|
||||
meta: {
|
||||
isLink: true
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export default routes;
|
||||
19
src/router/index.js
Normal file
19
src/router/index.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { createRouter, createWebHashHistory } from 'vue-router';
|
||||
import routesConfig from './config';
|
||||
// console.log('routesConfig', routesConfig)
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
name: '首页',
|
||||
redirect: routesConfig[0].path
|
||||
},
|
||||
...routesConfig
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user