当前位置:网站首页>Six ways of uniapp route jump

Six ways of uniapp route jump

2022-07-23 15:21:00 Like angels

uniapp Official documents Detailed explanation :

 Insert picture description here

One 、uni.navigateTo Keep the current page , Jump to a page in the app , Use uni.navigateBack You can go back to the original page .

uni.navigateTo({
    
	url:'./index/index'
});

Be careful :

  • The page Jump path has hierarchical restrictions , You can't jump to new pages without restrictions
  • Jump to tabBar The page can only use switchTab Jump

Two 、uni.redirectTo Close current page , Jump to a page in the app .

uni.redirectTo({
    
	url: './index/index'
});

3、 ... and 、uni.reLaunch Close all pages , Open to a page in the app .

uni.reLaunch({
    
	url: './index/index'
});

Four 、uni.switchTab Jump to tabBar page , And shut down all the others tabBar page .

uni.switchTab({
    
	url: '/pages/index/index'
});

Be careful :

  • Need to jump tabBar The path of the page ( stay pages.json Configured in the file tabBar page ), The path cannot be followed by parameters , It can be used uni.reLaunch Instead of

5、 ... and 、uni.navigateBack Close current page , Go back to the previous page or multi-level page . It can be done by getCurrentPages() Get the current page stack , Decide how many layers you need to go back .

uni.navigateBack({
    
	delta: 2  // Return to the two-tier page 
});
原网站

版权声明
本文为[Like angels]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207231041202228.html