在使用this.router.navigate(['../'],{relativeTo:this.route})进行路由跳转时,V1Component、V2Component都无法通过'../'、'../../'等方式回到上一级页面,而V3Component却可以,这是为什么呢?
relativeto文件目录
clipboard.png
relativeto路由
constroutes:Routes=[
{path:'',redirectTo:'page',pathMatch:'full'},
{
path:'page',
children:[
{path:'',component:PageComponent},
{
path:'v1',
children:[
{path:'',component:V1Component},
{
path:'v2',
children:[
{path:'',component:V2Component},
{path:'v3',component:V3Component}
]
}
]
},
]
}
];
v1
我是v1
goV2(){
this.router.navigate(['v2'],{relativeTo:this.route});
}
goV3(){
this.router.navigate(['v2/v3'],{relativeTo:this.route});
}
backPage(){
this.router.navigate(['../'],{relativeTo:this.route});//没反应
}