当前位置:网站首页>[wechat applet] page navigation details
[wechat applet] page navigation details
2022-07-21 18:18:00 【Oranges!】
Learning objectives of this section :
Learn how to use the navigation jump between pages
List of articles
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 :
url
Indicates the page address to jump to , Must be / startopen-strle
Indicates 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 :
url
Indicates the page address to jump to , Must be / startopen-style
Indicates 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-type
The value of must be navigateBack, Indicates that you want to perform back navigationdelta
The 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 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 .
边栏推荐
- leetcode:1125. 最小的必要团队【状压dp板子 + 集合覆盖板子】
- h5手机游戏奔跑吧兔子源码下载
- Creative paging style SVG animation JS special effects
- 图片、视频修复并超分 - Real-ESRGAN项目使用(一) | 机器学习
- 使用esp32 download tool给esp32烧录固件
- Don't know how to learn MySQL? It's enough to finish the 50 questions of Niuke! (Part VIII)
- Double disk: intelligent cockpit series article 6 - its three interactive ways of explicit interaction (voice and display)
- 复盘:智能座舱系列文五- 它的3种交互方式之隐式交互
- mogdb安装
- 二维码制作完成后,还能修改二维码的内容吗?
猜你喜欢
随机推荐
2163. 删除元素后和的最小差值【dp + heapq】
堆栈的区别
狂神redis笔记05
IDEA 忽略target目录
[test development] software testing - Test Case Design & detailed explanation of test classification
C# AES CBC模式 加密和解密
九. 实战——反射
MFC计算器
七. 实战——常用工具类的一些方法
网络安全学习(千锋网络安全笔记)4--用户与组管理
Crazy God redis notes 05
CAD浏览模式与绘图模式、CAD如何一次性打印上百张图纸
越来越多的场景和行业开始与元宇宙扯上关系
UE4 spring blueprint - survival development game
PKI证书体系
游戏心理学
Mogdb installation
CAD browsing mode and drawing mode, how CAD prints hundreds of drawings at one time
使用esp32 download tool给esp32烧录固件
TCP/IP基础