vue-element-admin,路由中只有一个页面时,router/index.js该怎么写?

发布于 2022-09-13 01:27:38 字数 1502 浏览 17 评论 0

  // 外部链接
  {
    path: '/userLinks',
    name: 'userLinks',
    component: '@/views/page/userLinks.vue',
    meta: {
      navigation: true,
      title: 'userLinks',
      icon: 'el-icon-link',
      rules: ["admin"]
    },
  },

上面的写法显示不了。

改成下面的代码,能显示,但是页面不跳转

    path: '/userLinks',
    component: Layout,
    redirect: '/userLinks',
    name: 'userLinks',
    meta: {
      navigation: true,
      title: 'userLinks',
      icon: 'el-icon-link',
      rules: ["admin"]
    },
    children: [
      {
        path: 'userLinks',
        component: () => import('@/views/page/userLinks.vue'),
        name: 'userLinks',
        meta: { 
          title: 'userLinks',
          navigation: true,
          noCache: true,
          icon: 'el-icon-link',
        }
      }
    ]

解决了,下面代码:

  // 外部链接
  {
    path: '/userLinks',
    component: Layout,
    name: 'userLinks',
    //当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
    redirect: '/userLinks/userLinks',
    meta: {
      navigation: true,
      title: 'userLinks',
      icon: 'el-icon-link',
      rules: ["admin"]
    },
    disabled: false,
    children: [
      {
        path: 'userLinks',
        name: 'userLinks',
        component: () => import('@/views/page/userLinks.vue'),
        meta: {
          // 用户链接
          title: 'userLinks',
          navigation: false,
          icon: 'el-icon-link'
        },
        disabled: false
      }
    ]
  },

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠北森屋 2022-09-20 01:27:38

类以这样

{
  path: '/charts',
  component: Layout,
  redirect: 'noRedirect',
  name: 'Charts',
  meta: {
    title: 'Charts',
    icon: 'chart'
  },
  children: [
    {
      path: 'keyboard',
      component: () => import('@/views/charts/keyboard'),
      name: 'KeyboardChart',
      meta: { title: 'Keyboard Chart', noCache: true }
    }
  ]
}

或者不需要公共layout

  {
    path: '/login',
    component: () => import('@/views/login/index')
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文