Home > Web Front-end > uni-app > body text

How to jump to the page in uni-app

青灯夜游
Release: 2023-01-13 00:44:42
Original
45384 people have browsed it

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);
 }
}
Copy after login

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
});
Copy after login

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);
   }
}
Copy after login

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'
});
Copy after login

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
});
Copy after login

[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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template