对于单页面应用来说,路由是核心功能。而 Umi 的路由既支持配置式,又支持约定式
https://zhuanlan.zhihu.com/p/398655814
动态路由
pages/
[id].js
生成的路由在 src/.umi/core/routes.ts
const routes = [
{
path: '/:id',
exact: true,
component: require('@/pages/[id].js').default
}
]
umi2 动态路由
$id.js
权限控制
admin 权限参考
export default [
{
// 没有 name属性,左侧菜单里面就不显示
// name: 'list.table-list',
icon: 'table',
path: '/list',
component: './TableList',
},
{
path: '/admin',
name: 'admin',
icon: 'crown',
access: 'canAdmin',
component: './Admin',
routes: [
{
path: '/admin/sub-page',
name: 'sub-page',
icon: 'smile',
component: './TableList',
},
],
},
]