vue相关问题

vue嵌套路由

2019-04-19  本文已影响4人  一条小团团ovo的就很棒

定义:路由中嵌套子路由,子路由中关键属性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"])
            }
        ]
  })
上一篇下一篇

猜你喜欢

热点阅读