Uniapp Navigation: Redirect to Specific Page
To set up redirection to a specific page in UniApp, you can utilize the uni.navigateTo() or uni.redirectTo() methods.
- Navigate to a new page using the uni.navigateTo() method.
uni.navigateTo({
url: '/pages/pageName/pageName'
});
In this case, ‘pageName’ is the name of the page to navigate to, which needs to be replaced according to the actual situation.
- Redirect to a new page using uni.redirectTo() method.
uni.redirectTo({
url: '/pages/pageName/pageName'
});
Unlike the uni.navigateTo() method, the uni.redirectTo() method will close the current page before navigating to the target page.
It is important to note that in UniApp, the paths for page navigation are relative and should be adjusted based on the actual project structure. Additionally, you can also use the uni.reLaunch() method to navigate to a specific page, which will close all pages before navigating to the target page.