umi 导航菜单的空白页问题

2023-10-29

主思路

routes里的上级菜单必须设定path,否则下一个二级菜单会出现空白页。

详情

umi的导航菜单是在 config/routes.ts 里设定的,比如:

export default [
  {
    name: 'home',
    path: '/home',
    component: './Home',
  },
  {
    name: 'test1',
    routes: [
      {
        path: '/test1/subtest1',
        name: 'subtest1',
        component: './subtest1',
      },
    ],
  },
  {
    name: 'test2',
    routes: [
      {
        path: '/test2/subtest2',
        name: 'subtest2',
        component: './subtest2',
      },
    ],
  },    
];

显示很正常,但点击 subtest2 的时候会有问题,显示一个空白页,但并没有其他错误。经过替换法,发现父菜单没有 path 导致的这个问题。

正确的routes.ts是这样的

export default [
  {
    name: 'home',
    path: '/home',
    component: './Home',
  },
  {
    name: &#
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

umi 导航菜单的空白页问题 的相关文章

随机推荐