情诗网 >套路情话 > 正文

vue嵌套路由

来源:情诗网    2021-01-26    分类:套路情话

定义:路由中嵌套子路由,子路由中关键属性children
例:

 <div>
     <router-view></router-view>
 <div>
  import Vue from "vue";
  import VueRouter from "vue-router";
  Vue.use(VueRouter);
  export default new VueRouter({
        mode:"history";
        routes:[
            {
                  path:"/",
                  redirect:"/login"
            },{
                  path:"/home",
                  component:resolve=>require(["../components/login.vue"]),
                  children:[
                        {
                           path:"/user",
                           component:resolve=>require(["../component/user.vue"])
                        }
                  ]
            },
            {
                  path:"/login",    
                  component:resolve=>require(["../components/login.vue"])
            }
        ]
  })

热门文章