vue-router(配置子路由--单页面多路由区域操作)

1.配置子路由:

import Post from "@components/Post"

export default new Router({

  routers:[

    {

      path:'/',

      component:Pos

    },

    {//配置自由路

      path:'/com',

      compontent:Com,

      children:[

          {

            path:'/'

          },

          {

            path:'com',

            component:Com

          }

        ]

    }

  ]

})

2.单页面多路由区域操作(页面出现多个router-view --通过name)

<router-view></router-view>

<router-view  name="main"></router-view>

路由配置:

export default new Router({

  routers:[

    path:'/',

    compontents:{

      default:Def,

      main:Main

    }

  ]

});

配置中compontents:{}对象;

原文地址:https://www.cnblogs.com/fangyinghua/p/9237505.html