2.0.1 • Published 4 years ago
vue-router-menu-auto v2.0.1
auto create vue routes for projects created by vue-cli
为vue-cli创建的工程提供自动创建 vue routes 能力
功能介绍
- 自动生vue-routes到 @/pages/routes/temp.routes.js
- 需要应用在符合 vue cli创建的工程,有 src/pages/router文件夹
- 请在工程根目录配置 temp.* 忽略以免报错,比如 .gitignore , .eslintignore
安装
npm i -SD vue-router-auto
const vueRouterAuto =require('vue-router-auto')
vueRouterAuto.run
需要在 @/pages/各个页面目录节点配置对应的meta.json作为页面发现线索
示例: meta.json
{
"menu": {//如果不需要展示主界面菜单上,则不配置 menu项
"title": "看板管理",
"icon": "el-icon-s-help"
},
"hideInBread": true,
"access": [
"ADMIN",
"USER VISITOR",
"GUEST",
"VISITOR"
]
}
生成结果示例 @/pages/routes/temp.routes.js
export default [{
path: '/router-1',
component: () => import('@/components/main'),
meta: {
"menu": {
"title": "页面1",
"icon": "el-icon-s-help"
},
"access": ["ADMIN", "USER VISITOR", "GUEST", "VISITOR"]
},
children: [{
path: '/',
name: 'router-1',
component: () => import('@/pages/router-1'),
}, ],
}, {
path: '/router-2',
component: () => import('@/components/main'),
meta: {
"menu": {
"title": "页面2",
"icon": "el-icon-s-help"
},
"access": ["ADMIN", "USER VISITOR", "GUEST", "VISITOR"]
},
children: [{
path: '/',
name: 'router-2',
component: () => import('@/pages/router-2'),
}, ],
}]
2.0.1
4 years ago