不努力code 2023-07-27 19:15 采纳率: 60%
浏览 5

多个router-view嵌套问题

我在使用vue-router中。一个页面使用多个router-view。我要在tabbarProfile中在加路由,遇到了嵌套问题

import type { RouteRecordRaw } from 'vue-router'
const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'index',
    component: () => import('@/view/index/index.vue'),
  },
  {
    path: '/tabbar',
    name: 'tabbar',
    redirect: (_) => ({ name: 'tabbarHome' }),
    component: () => import('@/view/tabbar/index.vue'),
    children: [
      {
        path: '',
        name: 'tabbarHome',
        components: {
          tabbarHome: () => import('@/view/tabbar/home/index.vue'),
          tabbarProfile: () => import('@/view/tabbar/profile/index.vue'),
        },
      
      },
    ],
  },
]

export default routes


我希望可以样这样,但是不行

import type { RouteRecordRaw } from 'vue-router'
const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'index',
    component: () => import('@/view/index/index.vue'),
  },
  {
    path: '/tabbar',
    name: 'tabbar',
    redirect: (_) => ({ name: 'tabbarHome' }),
    component: () => import('@/view/tabbar/index.vue'),
    children: [
      {
        path: '',
        name: 'tabbarHome',
        components: {
          tabbarHome: () => import('@/view/tabbar/home/index.vue'),
          tabbarProfile: {
            path: '',
            component: () => import('@/view/tabbar/profile/index.vue'),
            children,[...]
          },
        },
      },
    ],
  },
]

export default routes


  • 写回答

2条回答 默认 最新

  • 不努力code 2023-07-27 19:27
    关注

    我之所以需要这样。是因为我的tabbar是个swiper。需要定义多个router-view

    评论

报告相同问题?

问题事件

  • 创建了问题 7月27日

悬赏问题

  • ¥15 深度学习残差模块模型
  • ¥20 两个不同Subnet的点对点连接
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)