当前位置:网站首页>[applet development] page navigation details
[applet development] page navigation details
2022-07-25 18:39:00 【Hua Weiyun】

Learning objectives of this section :
Learn how to use the navigation jump between pages
@[toc]
One . Page navigation
What is page navigation
Page navigation It refers to the mutual jump between pages .
2. Two ways to realize page navigation
Page navigation has Two ways of implementation :
- Declarative navigation
Method : Declare a navigator Components , Click this component to jump to the page .
- Programming navigation
Method : Calling applet navigation API Realize page Jump .
Two . Declarative navigation
1. Navigate to tabBar page
tab Page fingers are configured as tabBar The page of , In the use of specified navigator When the component jumps to the specified page , Must specify url Properties and open-style attribute , among :
urlIndicates the page address to jump to , Must be / startopen-strleIndicates how to jump , This must beswitchTab
<navigator url="/pages/message/message" open-type="switchTab"> Jump to the message page </navigator>
2. Navigate to non tabBar page
Not tabBar A page is one that is not configured to tabBar The page of . In the use of naxigator Component jump to non tabBar When the page is , You also need to specify url Properties and open-type attribute , among :
urlIndicates the page address to jump to , Must be / startopen-styleIndicates how to jump , This must benavigate, At this point, this attribute can be omitted
<navigator url="/pages/info/info" open-type="navigate"> Jump to info page </navigator>
3. Back navigation
If you want to go back to the previous page or multi-level page , You need to specify open-type Properties and delta attribute , among :
open-typeThe value of must be navigateBack, Indicates that you want to perform back navigationdeltaThe value of must be a number , Indicates the level to go back , The default is 1
<navigator open-type="navigateBack" delta="1"> Go back to the previous page </navigator>
3、 ... and . Programming navigation
1. Navigate to tabBar page
call ==wx.switchTab(Object object)== Method , You can jump to tabBar page . among Object The attribute list of the parameter object is explained in the official document as follows :

wxml Code :
<button bindtap="gotoMessage" type="primary"> Jump to the message page </button>js Code :
gotoMessage(){ wx.switchTab({ url: '/pages/message/message',}) },
2. Navigate to non tabBar page
call ==wx.navigateTo(Object object)== Method , You can jump to non tabBar The page of . among Object The attribute list of the parameter object is explained in the official document as follows :
wxml\ Code :
<button bindtap="gotoinfo" type="primary"> Jump to info page </button>js Code :
gotoinfo(){ wx.navigateTo({ url: '/pages/info/info', }) },
3. Back navigation
call ==wx.navigateBack(Object object)== Method , You can return to the previous page or multiple pages . among Object The optional attribute list of the parameter object is explained in the official document as follows :
wxml Code :
<button bindtap="goBack"> Go back to the previous page </button>js Code :
goBack(){ wx.navigateBack({ delta: 1, }) },
Four . Navigation parameters
1. Declarative navigation parameters
navigator Component's url Attribute is used to specify that <fonr color=blue> The path of the page to jump to . meanwhile , Parameters can also be carried behind the path :
- Use... Between parameters and paths ? Separate
- Parameter key and parameter value = Connected to a
- Use... For different parameters & Separate
<navigator url="/pages/info/info?name=zs&age=20" open-type="navigate"> Jump to info page </navigator>2. Programming navigation parameters
call ==wx.navigateTo(Object object)== Method to jump to the page , You can also carry parameters .
gotoinfo(){ wx.navigateTo({ url: '/pages/info/info?name=ls&age=22', }) },3. stay onLoad Receive navigation parameters in
Parameters carried by declarative navigation parameters or programmatic navigation parameters , Can be directly in onLoad Get directly from the event .
data: { // Navigate the parameter object passed : Define an empty array of objects quary:{} }, onLoad(options) { console.log(options) this.setData({ quary:options})5、 ... and . summary
This section learned two ways of page navigation and two ways of navigating to tabBar Page and non tabBar The way of the page , And the method of navigation and parameter transmission .
边栏推荐
- Advanced software testing - test classification
- Twitter acquired a public opinion war, which was turned into a child quarrel by musk
- 3de 回复
- Experiment 2 goods purchase and sale management system
- Typescript反射对象Reflect使用
- What are the methods of traversing arrays? What is the difference between the performance of the for loop foreach for/in for/of map and how to choose?
- 对迁移学习中域适应的理解和3种技术的介绍
- String function and memory function (2)
- Design practice of Netease strictly selecting inventory center
- Automatic machine learning library: Tpot の learning notes
猜你喜欢
![[web page performance optimization] what about the slow loading speed of the first screen of SPA (single page application)?](/img/e2/9b62dd9bd0f2bc8dcbb6d9c851254d.png)
[web page performance optimization] what about the slow loading speed of the first screen of SPA (single page application)?

Introduction notes of JVM foundation and problem analysis

If you want to do a good job in software testing, you can first understand ast, SCA and penetration testing

Save the image with gaussdb (for redis), and the recommended business can easily reduce the cost by 60%

Optimistic lock resolution

Esp32 S3 vscode+idf setup

VC/PE正跑向青岛

How to build an enterprise level OLAP data engine for massive data and high real-time requirements?

Advanced software testing - test classification

Visual model network connection
随机推荐
[haoi2015] tree operation
How to build an enterprise level OLAP data engine for massive data and high real-time requirements?
Twitter acquired a public opinion war, which was turned into a child quarrel by musk
win11下vscode 自动升级失败 There was an error while marking a file for deletion
【帮助中心】为您的客户提供自助服务的核心选项
Nc68 jumping steps
Application of current probe in ECU and electrical system current measurement
There was an error while marking a file for deletion
C盘空间不够 mklink解决VScode扩展迁移到其他盘
单臂路由实验演示(Huawei路由器设备配置)
Tensor to img && imge to tensor (pytorch的tensor转换)
3de 回复
Esp32 S3 vscode+idf setup
C language -- 25 minesweeping game
Paper revision reply 1
NC15 求二叉树的层序遍历
JVM基础和问题分析入门笔记
TypeError: Unrecognized value type: <class ‘str‘> ParserError: Unknown string format
#夏日挑战赛#【FFH】这个盛夏,来一场“清凉”的代码雨!
电流探头在ECU、电气系统电流测量的应用