Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vue.js 如何将外部布局添加到vue组件_Vue.js_Vue Router - Fatal编程技术网

Vue.js 如何将外部布局添加到vue组件

Vue.js 如何将外部布局添加到vue组件,vue.js,vue-router,Vue.js,Vue Router,我想将我的vue路由从/dashboards/dashboard更改为just/dashboard。如何使用此代码实现这些功能 import Layout2 from '@/layout/Layout2' export default [ { path: '/dashboards', component: Layout2, children: [ { path: 'dashboard', name: 'dashboard',

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

import Layout2 from '@/layout/Layout2'

export default [
{
    path: '/dashboards',
    component: Layout2,
    children: [
    {
        path: 'dashboard',
        name: 'dashboard',
        component: () => import('@/components/dashboards/Dashboard')
    }
    ]
  }
]
我已经尝试过添加这些代码,但是如果已经添加了组件,如何添加布局2

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

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

你能行

import Layout2 from '@/layout/Layout2'

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

谢谢你的帮助,并把文档链接和解释。非常感谢。