当前位置:网站首页>[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 .
边栏推荐
猜你喜欢

关爱一线防疫工作者,浩城嘉业携手高米店街道办事处共筑公益长城

如何创建一个有效的帮助文档?

What is 3DE experience platform
![[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)?

7. Dependency injection

Safe operation instructions for oscilloscope probe that must be read by engineers

动态内存管理

Interview shock: why does TCP need three handshakes?

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

ZFS - 01 - basic operations of creating and expanding zpool
随机推荐
想要做好软件测试,可以先了解AST、SCA和渗透测试
#夏日挑战赛#【FFH】这个盛夏,来一场“清凉”的代码雨!
You can change this value on the server by setting the 'Max_ allowed_ Packet 'variable error
Esp32 S3 vscode+idf setup
11.2-HJ86 求最大连续bit数
曾拿2亿融资,昔日网红书店如今全国闭店,60家店仅剩3家
GAN的详细介绍及其应用(全面且完整)
Disk performance and capacity
用GaussDB(for Redis)存画像,推荐业务轻松降本60%
JVM基础和问题分析入门笔记
推特收购舆论战,被马斯克变成了小孩吵架
How developers choose the right database for react native
Partial correlation calculation of R language and partial correlations calculation using pcor function of GGM package
How to create an effective help document?
《21天精通TypeScript-4》-类型推断与语义检查
rust多线程安全计数
Analysis of regression problem, modeling and prediction
Ceres analytic derivation
[QNX hypervisor 2.2 user manual]9.4 dryrun
Application of current probe in ECU and electrical system current measurement