但是感觉umi的约定式路由对复杂点的路径和嵌套路由都不怎么友好。对于嵌套路由还得按着要求建_layout,觉得是增加了学习成本。
于是还是得配置下routes:
和vue-router不同,umi(react)的路由用起来很别扭,怕忘记了因此记下来。
项目结构
├─charts
│ └─pages
│ ├─chart
│ └─data
│ └─components
│ ├─ChartTypeSelect
│ ├─DimensionSelect
│ └─HotTable
└─test
首先,不按约定路由格式建立项目结构的话,就必须使用.umirc.js内的routes属性定义路由 需要指定引用的组件routes: [
{
path: '/',
component: '@/pages/index',
routes: [
{ path: '/test', component: '@/pages/test/index' },
{
path: '/charts/',
component: '@/pages/charts/index',
routes:
[
{ path: '/charts/data', component: '@/pages/charts/pages/data/index' },
],
},
],
},
],