Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the relativeTo parameter jump of Router.navigate in javascript and Angular

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how to use the relativeTo parameter jump of Router.navigate in javascript and Angular. I hope you will get something after reading this article. Let's discuss it together.

When using this.router.navigate (['.. /'], {relativeTo:this.route}) for route redirection, V1Component and V2Component cannot return to the previous page by means of'.. /','.. /.. /', but V3Component can. Why?

Relativeto file directory

Clipboard.png

Relativeto routing

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

I'm v1.

Enter v2

Enter v3

Back to page

GoV2 () {

This.router.navigate (['v2'], {relativeTo:this.route})

}

GoV3 () {

This.router.navigate (['v2amp v3'], {relativeTo:this.route})

}

BackPage () {

This.router.navigate (['.. /'], {relativeTo:this.route}); / / No response

}

After reading this article, I believe you have a certain understanding of "how to use the relativeTo parameter jump of Router.navigate in javascript and Angular". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report