search
HomeWeb Front-enduni-appHow to jump to the page in uni-app

How to jump to the page in uni-app

Sep 15, 2021 am 11:18 AM
uni-appPage jump

Jump method: 1. Use "uni.navigateTo(OBJECT)"; 2. Use "uni.redirectTo(OBJECT)"; 3. Use "uni.reLaunch(OBJECT)"; 4. Use " uni.switchTab(OBJECT)" etc.

How to jump to the page in uni-app

The operating environment of this tutorial: windows7 system, uni-app version 2.5.1, DELL G3 computer.

uni-app Page jump is mainly completed by the following 5 methods. They are as follows:

(1)uni.navigateTo(OBJECT) Keep the current page and jump to a page in the application
(2)uni.redirectTo(OBJECT) Close the current page, Jump to a page in the application
(3)uni.reLaunch(OBJECT) Close all pages and open a page in the application
(4)uni.switchTab(OBJECT) Jump to the tabBar page , and close all other non-tabBar pages
(5)uni.navigateBack(OBJECT) Close the current page and return to the previous page or multi-level page

uni.navigateTo(OBJECT)

Keep the current page, jump to a page in the application, and use uni.navigateBack to return to the original page. OBJECT parameter description: Parameter type is required. Description: urlString is the path to the non-tabBar page in the application that needs to be jumped. Parameters can be included after the path. Parameters and paths are separated by ?, parameter keys and parameter values ​​are connected by =, and different parameters are separated by &;

uni.navigateTo({
url: 'test?id=1&name=uniapp'

});
export default {
onLoad: function (option) {
console.log(option.id);
console.log(option.name);
 }
}

uni.redirectTo(OBJECT)

Close Current page, jump to a page within the application. OBJECT Parameter Description Parameter Type Required Description urlString is the path to the non-tabBar page in the application that needs to be jumped. Parameters can be included after the path. Use ? to separate parameters and paths, connect parameter keys and parameter values ​​with =, and separate different parameters with &;

uni.redirectTo({
url: 'test?id=1' // 传递参数 id,值为1
});

uni.reLaunch(OBJECT)

Close All pages, open to a page within the application. OBJECT parameter description: Parameter type is required. Description urlString is the path to the page within the application that needs to be jumped. Parameters can be included after the path. Parameters and paths are separated by ?, parameter keys and parameter values ​​are connected by =, and different parameters are separated by &;

uni.reLaunch({
url: 'test?id=1'
});
export default {
onLoad: function (option) {
console.log(option.query);
   }
}

uni.switchTab(OBJECT)

Jump Go to the tabBar page and close all other non-tabBar pages. OBJECT parameter description: Parameter type is required. Description: urlString is the path to the tabBar page that needs to be jumped (the page needs to be defined in the tabBar field of app.json). Parameters

pages.json{
"tabBar": {
"list": [
{
"pagePath": "index",
"text": "首页"
},{
"pagePath": "other",
"text": "其他"
      }]
   }
}
other.vueuni.switchTab({
url: 'index'
});

uni are not allowed after the path. navigateBack(OBJECT)

Close the current page and return to the previous page or multi-level page. You can get the current page stack through getCurrentPages() and decide how many levels to return. OBJECT parameter description: Parameter type is required. Description deltaNumber1 The number of pages returned. If delta is greater than the number of existing pages, return to the homepage.

uni.navigateTo({
url: 'B?id=1'
});
uni.navigateTo({
url: 'C?id=1'
});
uni.navigateBack({
delta: 2
});

[Related recommendations: "uniapp tutorial"]

The above is the detailed content of How to jump to the page in uni-app. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How do you debug issues on different platforms (e.g., mobile, web)?How do you debug issues on different platforms (e.g., mobile, web)?Mar 27, 2025 pm 05:07 PM

The article discusses debugging strategies for mobile and web platforms, highlighting tools like Android Studio, Xcode, and Chrome DevTools, and techniques for consistent results across OS and performance optimization.

What debugging tools are available for UniApp development?What debugging tools are available for UniApp development?Mar 27, 2025 pm 05:05 PM

The article discusses debugging tools and best practices for UniApp development, focusing on tools like HBuilderX, WeChat Developer Tools, and Chrome DevTools.

How do you perform end-to-end testing for UniApp applications?How do you perform end-to-end testing for UniApp applications?Mar 27, 2025 pm 05:04 PM

The article discusses end-to-end testing for UniApp applications across multiple platforms. It covers defining test scenarios, choosing tools like Appium and Cypress, setting up environments, writing and running tests, analyzing results, and integrat

What are the different types of testing that you can perform in a UniApp application?What are the different types of testing that you can perform in a UniApp application?Mar 27, 2025 pm 04:59 PM

The article discusses various testing types for UniApp applications, including unit, integration, functional, UI/UX, performance, cross-platform, and security testing. It also covers ensuring cross-platform compatibility and recommends tools like Jes

What are some common performance anti-patterns in UniApp?What are some common performance anti-patterns in UniApp?Mar 27, 2025 pm 04:58 PM

The article discusses common performance anti-patterns in UniApp development, such as excessive global data use and inefficient data binding, and offers strategies to identify and mitigate these issues for better app performance.

How can you use profiling tools to identify performance bottlenecks in UniApp?How can you use profiling tools to identify performance bottlenecks in UniApp?Mar 27, 2025 pm 04:57 PM

The article discusses using profiling tools to identify and resolve performance bottlenecks in UniApp, focusing on setup, data analysis, and optimization.

How can you optimize network requests in UniApp?How can you optimize network requests in UniApp?Mar 27, 2025 pm 04:52 PM

The article discusses strategies for optimizing network requests in UniApp, focusing on reducing latency, implementing caching, and using monitoring tools to enhance application performance.

How can you optimize images for web performance in UniApp?How can you optimize images for web performance in UniApp?Mar 27, 2025 pm 04:50 PM

The article discusses optimizing images in UniApp for better web performance through compression, responsive design, lazy loading, caching, and using WebP format.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools