效果如下
const Fans = ()=> import(/*wbpackChunkName:"space"*/ '@/views/user-space/fans');
const MenuList = ()=> import(/*wbpackChunkName:"space"*/ '@/views/user-space/menu-list');
// const Register =() => import('@/views/user-login/register');
const router = new Router({
mode:"history",
routes:[{
path:'/',
name:"Home",
component:Home
},
{
path:'/detail',
name:"detail",
component:Detail
},
{
path:'*',
name:'noFound',
title:'未找到',
redirect:{
name:'home'
}
},
{
path:'/login',
name:'login',
component:Login,
meta:{
login:true
}
},
{
path:'/space',
name:'space',
component:Space,
redirect:{
name:'works'
},
meta:{
login:true
},
children:[
{
path:'works',
name:'works',
component:MenuList,
meta:{
login:true
}
},
{
path:'fans',
name:'fans',
component:Fans,
meta:{
login:true
}
},
{
path:'following',
name:'following',
component:Fans,
meta:{
login:true
}
},
{
path:'collection',
name:'collection',
component:MenuList,
meta:{
login:true
}
}
]
}
]
});
然后在个人空间页通过router-view来进行路由的切换效果
然后再请求四个子路由的接口
然后通过我们上面在router-view上绑定的tab-click事件实现此次效果