vue命名视图
2019-04-22 本文已影响3人
一条小团团ovo的就很棒
-
命名视图
定义:同一路由,多种路径
步骤:
1.页面上:
<div>
<router-view></router-view>
<router-view name="home"></router-view>
</div>
2.配置路由规则时:
import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);
export default new VueRouter({
mode:"history",
routes:[
{
path:"/",
redirect:"/login"
},
{
path:"/home",
components:{
default:home,sidebar:sidebar //default表示默认的视图容器
},
component:resolve=>require(["../components/home.vue"],resolve)
},
{
path:"/login",
component:resolve=>require(["../components/login.vue"],resolve)
}
]
})