vue 默认子路由不生效

当一个路由配置文件里有定义了两个路由时,默认子路由会不生效

export default [
{
    path: '/store',
   // name属性删除
    name:"xxxx",
    component: () => import('@/page/store/index'),
    children: [
        {
            path: '',
            redirect: {
                name: 'storeHome'
            },
        },
        {
            path: 'home',
            component: () => import('@/page/store/home'),
            name: 'storeHome',
        },
        {
            path: 'hot',
            component: () => import('@/page/store/hot'),
            name: 'storeHot',
        }
},
{
    path: '/storeLiji',
      // name属性删除
    name:"xxxx",
    component: () => import('@/page/storeLiji/index'),
    children: [
        {
            path: '',
            redirect: {
                name: 'storeHomeLiji',
            },
        },
        {
            path: 'home',
            component: () => import('@/page/storeLiji/home'),
            name: 'storeHomeLiji',
        },
        {
            path: 'hot',
            component: () => import('@/page/storeLiji/hot'),
            name: 'storeHotLiji',
        },    
},
 ]

这时候需要把父路由的name删掉,(name:“xxx”)
然后 router-link指向路径改成默认子路由的name

  :to="{name: 'xxx'}
  //改成下例
  :to="{name: 'storeHomeLiji'}

你可能感兴趣的:(vue,vue,默认子路由)