【问题标题】:How to add a outside layout to vue component如何为 vue 组件添加外部布局
【发布时间】:2019-07-11 08:33:47
【问题描述】:

我想将我的 vue 路由从 /dashboards/dashboard 更改为 /dashboard。如何使用此代码实现这些

import Layout2 from '@/layout/Layout2'

export default [
{
    path: '/dashboards',
    component: Layout2,
    children: [
    {
        path: 'dashboard',
        name: 'dashboard',
        component: () => import('@/components/dashboards/Dashboard')
    }
    ]
  }
]

我已尝试放置这些代码,但如果组件已添加,我该如何添加 layout2?

export default [
  {
    path: '/dashboard',
    name: 'dashboard',
    component: () => import('@/components/dashboards/Dashboard')
  }
]

【问题讨论】:

    标签: vue.js vue-router


    【解决方案1】:

    如果vue-router document

    请注意,以 / 开头的嵌套路径将被视为根 小路。这允许您利用组件嵌套而无需 使用嵌套 URL。

    你可以的

    import Layout2 from '@/layout/Layout2'
    
    export default [
    {
        path: '/',
        component: Layout2,
        children: [
        {
            path: 'dashboard',
            name: 'dashboard',
            component: () => import('@/components/dashboards/Dashboard')
        }
        ]
      }
    ]
    

    【讨论】:

    • 感谢您的帮助并提供文档链接和解释。真的很感激。
    猜你喜欢
    • 2019-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多